string.IsNullOrEmpty(string)

Here are the examples of the csharp api class string.IsNullOrEmpty(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

101. Example

Project: boxcli
Source File: FileVersionSubCommandBase.cs
View license
protected void CheckForFileVersionId(string id, CommandLineApplication app)
        {
            if (string.IsNullOrEmpty(id))
            {
                app.ShowHelp();
                throw new Exception("A file version ID is required for this command.");
            }
        }

102. Example

Project: boxcli
Source File: BoxDefaultSettings.cs
View license
private BoxHomeDefaultSettings SetBoxDownloadsFolderPathIfNull(BoxHomeDefaultSettings settings)
        {
            if (string.IsNullOrEmpty(settings.BoxDownloadsFolderPath))
            {
                var path = $"{_boxHome.GetBaseDirectoryPath()}{Path.DirectorySeparatorChar}Downloads{Path.DirectorySeparatorChar}{settings.BoxDownloadsFolderName}";
                settings.BoxDownloadsFolderPath = path;
            }
            return settings;
        }

103. Example

Project: PlainElastic.Net
Source File: PrefixFilter.cs
View license
public PrefixFilter<T> Prefix(string prefix)
        {
            if (!prefix.IsNullOrEmpty())
            {
                RegisterJsonPart("'prefix': {0}", prefix.Quotate());
                hasValue = true;
            }

            return this;
        }

104. Example

Project: PlainElastic.Net
Source File: RangeBase.cs
View license
public TQuery Gt(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                hasValue = true;
                RegisterJsonPart("'gt': {0}", value.Quotate());
            }
            return (TQuery)this;
        }

105. Example

Project: PlainElastic.Net
Source File: MissingFilter.cs
View license
protected override string ApplyJsonTemplate(string body)
        {
            if (!RegisteredField.IsNullOrEmpty())
            {
                var field = "'field': {0}".AltQuoteF(RegisteredField);

                if (!body.IsNullOrEmpty())
                    body = new[] { field, body }.JoinWithComma();
                else
                    body = field;
            }
            else if (!HasCustomPatrs)
                return "";
            
            return "{{ 'missing': {{ {0} }} }}".AltQuoteF(body);
        }

106. Example

Project: PlainElastic.Net
Source File: ExistsFilter.cs
View license
protected override string ApplyJsonTemplate(string body)
        {
            if (!RegisteredField.IsNullOrEmpty())
            {
                var field = "'field': {0}".AltQuoteF(RegisteredField);

                if (!body.IsNullOrEmpty())
                    body = new[] { field, body }.JoinWithComma();
                else
                    body = field;
            }
            else if (!HasCustomPatrs)
                return "";

            return "{{ 'exists': {{ {0} }} }}".AltQuoteF(body);
        }

107. Example

Project: PlainElastic.Net
Source File: FieldQuery.cs
View license
public FieldQuery<T> Query(string value)
        {
            if (value.IsNullOrEmpty())
                return this;

            RegisterJsonPart("'query': {0}", value.Quotate());
            hasValue = true;
            return this;
        }

108. Example

Project: PlainElastic.Net
Source File: NestedObject.cs
View license
protected override string ApplyMappingTemplate(string mappingBody)
        {
            if (mappingBody.IsNullOrEmpty())
                return "{0}: {{ 'type': 'nested' }}".AltQuoteF(Name.Quotate());

            return "{0}: {{ 'type': 'nested',{1} }}".AltQuoteF(Name.Quotate(), mappingBody);
        }

109. Example

Project: PlainElastic.Net
Source File: FuzzyQuery.cs
View license
public FuzzyQuery<T> Value(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                RegisterJsonPart("'value': {0}", value.Quotate());
                hasValue = true;
            }

            return this;
        }

110. Example

Project: PlainElastic.Net
Source File: PropertyBase.cs
View license
protected override string ApplyMappingTemplate(string mappingBody)
        {
            if (mappingBody.IsNullOrEmpty())
                return "{0}: {{ 'type': {1} }}".AltQuoteF(FieldName.Quotate(), FieldType.Quotate());

            return "{0}: {{ 'type': {1},{2} }}".AltQuoteF(FieldName.Quotate(), FieldType.Quotate(), mappingBody);
        }

111. Example

View license
public GeoDistanceFilter<T> Geohash(string geohash)
        {
            if (geohash.IsNullOrEmpty())
                return this;

            RegisterJsonPart("'{0}': '{1}'", RawFieldName, geohash);

            hasPoint = true;

            return this;
        }

112. Example

View license
public FuzzyLikeThisQuery<T> LikeText(string likeText)
        {
            if (likeText.IsNullOrEmpty())
                return this;
             
            RegisterJsonPart("'like_text': {0}", likeText.Quotate());
            hasValue = true;
            return this;
        }

113. Example

View license
public static bool IsNullOrEmpty(this string source)
        {
            return String.IsNullOrEmpty(source);
        }

114. Example

Project: PlainElastic.Net
Source File: RangeBase.cs
View license
public TQuery Lte(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                hasValue = true;
                RegisterJsonPart("'lte': {0}", value.Quotate());
            }
            return (TQuery)this;
        }

115. Example

View license
public MoreLikeThisQuery<T> LikeText(string likeText)
        {
            if (likeText.IsNullOrEmpty())
                return this;

            RegisterJsonPart("'like_text': {0}", likeText.Quotate());
            hasValue = true;
            return this;
        }

116. Example

Project: PlainElastic.Net
Source File: RangeBase.cs
View license
public TQuery To(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                hasValue = true;
                RegisterJsonPart("'to': {0}", value.Quotate());
            }

            return (TQuery)this;
        }

117. Example

Project: PlainElastic.Net
Source File: WildcardQuery.cs
View license
public WildcardQuery<T> Value(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                RegisterJsonPart("'value': {0}", value.Quotate());
                hasValue = true;
            }

            return this;
        }

118. Example

Project: PlainElastic.Net
Source File: Attachment.cs
View license
protected override string ApplyMappingTemplate(string mappingBody)
        {
            if (mappingBody.IsNullOrEmpty())
                return "{0}: {{ 'type': 'attachment' }}".AltQuoteF(Name.Quotate());

            return "{0}: {{ 'type': 'attachment',{1} }}".AltQuoteF(Name.Quotate(), mappingBody);
        }

119. Example

Project: PlainElastic.Net
Source File: GetCommand.cs
View license
public GetCommand Preference(GetPrefernce prefernce, string customPreference = null)
        {
            string value = prefernce.AsString();
            if (prefernce == GetPrefernce.custom)
                value = customPreference;

            if (!value.IsNullOrEmpty())
                WithParameter("preference", value);

            return this;
        }

120. Example

View license
public GeoDistanceFilter<T> Distance(string distance)
        {
            if (distance.IsNullOrEmpty())
                return this;

            RegisterJsonPart("'distance': {0}", distance.Quotate());

            hasDistance = true;

            return this;
        }

121. Example

Project: PlainElastic.Net
Source File: RootObject.cs
View license
protected override string ApplyMappingTemplate(string mappingBody)
        {
            if (mappingBody.IsNullOrEmpty())
                return "{0}: {{ }}".AltQuoteF(Name.Quotate());

            return "{0}: {{ {1} }}".AltQuoteF(Name.Quotate(), mappingBody);
        }

122. Example

Project: PlainElastic.Net
Source File: RangeBase.cs
View license
public TQuery From(string value)
        {
            if (!value.IsNullOrEmpty())
            {
                hasValue = true;
                RegisterJsonPart("'from': {0}", value.Quotate());
            }
            return (TQuery)this;
        }

123. Example

View license
public FuzzyLikeThisFieldQuery<T> LikeText(string likeText)
        {
            if (likeText.IsNullOrEmpty())
                return this;

            RegisterJsonPart("'like_text': {0}", likeText.Quotate());
            hasValue = true;
            return this;
        }

124. Example

View license
public string GetKey()
    {
      var key = _tenantContext.Key;
      return string.IsNullOrEmpty(key) ? NHibernateSession.DefaultFactoryKey : key;
    }

125. Example

Project: FieldLog
Source File: LogSelectionView.cs
View license
private void UpdateButtons()
		{
			MainForm.Instance.BackEnabled = false;
			MainForm.Instance.NextEnabled =
				!dirListMode && !string.IsNullOrEmpty(SelectedLogDirText.Text) ||
				dirListMode && LogDirsListView.SelectedItems.Count > 0;
		}

126. Example

Project: FieldLog
Source File: FieldLogWebRequestData.cs
View license
internal static FieldLogWebRequestData Read(FieldLogFileReader reader)
		{
			FieldLogWebRequestData data = new FieldLogWebRequestData();
			data.RequestUrl = reader.ReadString();
			data.Method = reader.ReadString();
			data.ClientAddress = reader.ReadString();
			data.ClientHostName = reader.ReadString();
			data.Referrer = reader.ReadString();
			data.UserAgent = reader.ReadString();
			data.AcceptLanguages = reader.ReadString();
			data.Accept = reader.ReadString();
			data.WebSessionId = reader.ReadString();
			data.AppUserId = reader.ReadString();
			data.AppUserName = reader.ReadString();

			// Check if the environment is actually empty
			if (string.IsNullOrEmpty(data.RequestUrl))
				return FieldLogWebRequestData.Empty;

			return data;
		}

127. Example

Project: TxTranslation
Source File: MainViewModel.cs
View license
private bool CanSetPrimaryCulture()
		{
			return !string.IsNullOrEmpty(SelectedCulture) && SelectedCulture != PrimaryCulture;
		}

128. Example

Project: TxTranslation
Source File: TextKeyViewModel.cs
View license
public bool IsEmpty()
		{
			if (!string.IsNullOrEmpty(Comment)) return false;
			foreach (var ct in CultureTextVMs)
			{
				if (!ct.IsEmpty()) return false;
			}
			return true;
		}

129. Example

Project: TxTranslation
Source File: MainViewModel.cs
View license
private void UpdateTitle()
		{
			if (!string.IsNullOrEmpty(loadedFilePath))
			{
				DisplayName =
					loadedFilePrefix +
					(FileModified ? "*" : "") +
					(fileVersion == 1 ? " (v1)" : "") +
					" " + Tx.T("window.title.in path") + " " + loadedFilePath + " – TxEditor";
			}
			else
			{
				DisplayName = "TxEditor";
			}
		}

130. Example

View license
public bool IsEmpty()
		{
			if (!string.IsNullOrEmpty(Text)) return false;
			foreach (var qt in QuantifiedTextVMs)
			{
				if (!qt.IsEmpty()) return false;
			}
			return true;
		}

131. Example

View license
public bool IsEmpty()
		{
			return string.IsNullOrEmpty(Text);
		}

132. Example

View license
private static void TextChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
		{
			DecoratedTextBox dt = depObj as DecoratedTextBox;
			if (dt != null)
			{
				dt.PlaceholderVisibility = string.IsNullOrEmpty(args.NewValue as string) ? Visibility.Visible : Visibility.Collapsed;
				dt.IsEditing = true;
			}
		}

133. Example

Project: TxTranslation
Source File: MainViewModel.cs
View license
private void OnViewDateTimeFormats()
		{
			if (dateTimeWindow.IsClosed())   // Extension method, accepts null
			{
				dateTimeWindow = new DateTimeWindow();
				dateTimeWindow.Owner = MainWindow.Instance;
			}
			if (!string.IsNullOrEmpty(SelectedCulture))
			{
				dateTimeWindow.Culture = SelectedCulture;
			}
			else if (!string.IsNullOrEmpty(PrimaryCulture))
			{
				dateTimeWindow.Culture = PrimaryCulture;
			}
			else
			{
				return;
			}
			dateTimeWindow.Show();
		}

134. Example

Project: TxTranslation
Source File: MainViewModel.cs
View license
private bool CanDeleteCulture()
		{
			return !string.IsNullOrEmpty(SelectedCulture);
		}

135. Example

Project: vvvv_tutorial
Source File: Behavior.Occluder.cs
View license
private static void OnIsOccluderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = d as FrameworkElement;
            if (null == element) { return; }

            // Make sure there is a unique id set on the element
            if (string.IsNullOrEmpty(element.Uid))
            {
                element.Uid = InteractorIDGenerator.CreateUniqueID();
            }

            element.Unloaded += OnOccluderElementUnloaded;

            var occluderBehavior = new OccluderBehavior();
            var wpfInteractor = element.GetWpfInteractorOrDefault();
            wpfInteractor.AddBehavior(element, occluderBehavior);
        }

136. Example

Project: ArangoDB-NET
Source File: ADocument.cs
View license
public static bool IsKey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return false;
            }
            
            return ASettings.KeyRegex.IsMatch(key);
        }

137. Example

Project: ArangoDB-NET
Source File: ADocument.cs
View license
public static bool IsRev(string revision)
        {
            if (string.IsNullOrEmpty(revision))
            {
                return false;
            }
            
            return true;
        }

138. Example

Project: ArangoDB-NET
Source File: Response.cs
View license
internal T ParseBody<T>()
        {
            if (string.IsNullOrEmpty(Body))
            {
                return default(T);
            }

            return JSON.ToObject<T>(Body);
        }

139. Example

Project: ArangoDB-NET
Source File: ADocument.cs
View license
public static string Identify(string collection, long key)
        {
            if (string.IsNullOrEmpty(collection))
            {
                return null;
            }
            
            return collection + "/" + key;
        }

140. Example

Project: uwp_AiJianShu
Source File: IsolatedStorage.cs
View license
public T GetItem<T>(string key) where T : class
        {
            string value = container.Values[key]?.ToString();
            if (string.IsNullOrEmpty(value))
            {
                return default(T);
            }
            else
            {
                return Deserialize<T>(value);
            }
        }

141. Example

Project: uwp_AiJianShu
Source File: Untils.cs
View license
private static async Task<bool> WeiboShare(string url, string text)
        {
            CacheProvider cache = new CacheProvider(StorageType.IsolatedStorage);

            if (GlobalValue.CurrentWeiboUserInfo == null)
            {
                GlobalValue.CurrentWeiboUserInfo = cache.GetItem<UserInfo>(CacheKey.WeiboUser) ?? new UserInfo();
            }
            byte[] image = await new HttpClient().GetByteArrayAsync(url);

            bool shareResult = false;

            try
            {
                WeiboClient client = new WeiboClient(GlobalValue.CurrentWeiboUserInfo);
                await client.LoginAsync();
                WeiboResult result;
                if (!string.IsNullOrEmpty(url))
                {
                    result = await client.ShareImageAsync(image, text);
                }
                else
                {
                    result = await client.ShareTextAsync(text);
                }
                GlobalValue.CurrentWeiboUserInfo = client.UserInfo;

                cache.UpdateItem(CacheKey.WeiboUser, GlobalValue.CurrentWeiboUserInfo);
                shareResult = true;
            }
            catch
            {
                shareResult = false;
            }
            return shareResult;
        }

142. Example

Project: uwp_AiJianShu
Source File: UserInfo.cs
View license
public bool CheckUseable()
        {
            return !string.IsNullOrEmpty(Token) &&
                !string.IsNullOrEmpty(Uid) &&
                Untils.FromTimestamp(ExpiresAt) > DateTime.Now;
        }

143. Example

View license
[Signal]
	public void Authenticate(string userName, string passwordHash)
	{
		// process the user's credentials - for now we're just checking for null/empty string to keep it simple for this example
		if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passwordHash))
		{
			// user authenticated successfully - assign player name within this peer's ExamplePeer instance
			SenderPeer.SetAuthenticated(userName);

			// ..then send peer to the Lobby scope
			HandoverPeer(SenderPeer, ExampleServer.Lobby);
		}
		// if they couldn't be authenticated, we might as well disconnect them
		else
		{
			// TODO: we might want to send a disconnection reason rather than just closing the connection
			SenderPeer.Disconnect();
		}
	}

144. Example

Project: NuGet.Extensions
Source File: NuspecBuilder.cs
View license
public void SetMetadata(INuspecDataSource nuspecData, ICollection<ManifestDependency> manifestDependencies)
        {
            var metadata = _manifest.Metadata;
            metadata.Id = nuspecData.Id ?? metadata.Id;
            metadata.Title = nuspecData.Title ?? metadata.Title;
            metadata.Version = "$version$";
            metadata.Description = nuspecData.Description ?? metadata.Description;
            metadata.Authors = nuspecData.Author ?? "$author$";
            metadata.Tags = nuspecData.Tags ?? "$tags$";
            metadata.LicenseUrl = nuspecData.LicenseUrl ?? "$licenseurl$";
            metadata.RequireLicenseAcceptance = nuspecData.RequireLicenseAcceptance;
            metadata.Copyright = nuspecData.Copyright ?? "$copyright$";
            metadata.IconUrl = nuspecData.IconUrl ?? "$iconurl$";
            metadata.ProjectUrl = nuspecData.ProjectUrl ?? "$projrcturl$";
            metadata.Owners = nuspecData.Owners ?? nuspecData.Author ?? "$author$";

            //Dont add a releasenotes node if we dont have any to add...
            if (!String.IsNullOrEmpty(nuspecData.ReleaseNotes)) metadata.ReleaseNotes = nuspecData.ReleaseNotes;
        }

145. Example

Project: NuGet.Extensions
Source File: Copy.cs
View license
private void InstallPackageLocally(string packageId, string workDirectory) {
            var install = new InstallCommand();
            install.Arguments.Add(packageId);
            install.OutputDirectory = workDirectory;
            install.Console = Console;
            foreach (string source in Sources) {
                install.Source.Add(source);
            }
            if (!string.IsNullOrEmpty(Version)) {
                install.Version = Version;
            }

            install.ExecuteCommand();
        }

146. Example

Project: NuGet.Extensions
Source File: TeamCity.cs
View license
private static void SetNodeDetails(DirectedGraphNode n, string background, string shape, string category)
        {
            if (!string.IsNullOrEmpty(background))
                n.Background = background;
            if (!string.IsNullOrEmpty(shape))
                n.Shape = shape;
            n.Category = new DirectedGraphNodeCategory[]
                             {
                                 new DirectedGraphNodeCategory {Ref = category}
                             };
        }

147. Example

Project: vsLua
Source File: WikiTextTerminal.cs
View license
public override void Init(GrammarData grammarData) {
      base.Init(grammarData);
      var stopCharSet = new CharHashSet();
      foreach(var term in grammarData.Terminals) {
        var firsts = term.GetFirsts(); 
        if (firsts == null) continue; 
        foreach (var first in firsts)
          if (!string.IsNullOrEmpty(first))
            stopCharSet.Add(first[0]); 
      }//foreach term
      if (EscapeChar != NoEscape)  
        stopCharSet.Add(EscapeChar);
      _stopChars = stopCharSet.ToArray(); 
    }

148. Example

Project: vsLua
Source File: _WikiTerminalBase.cs
View license
public override void Init(GrammarData grammarData) {
      base.Init(grammarData);
      if (!string.IsNullOrEmpty(HtmlElementName)) {
        if (string.IsNullOrEmpty(OpenHtmlTag)) OpenHtmlTag = "<" + HtmlElementName + ">";
        if (string.IsNullOrEmpty(CloseHtmlTag)) CloseHtmlTag = "</" + HtmlElementName + ">";
      }
      if (!string.IsNullOrEmpty(ContainerHtmlElementName)) {
        if (string.IsNullOrEmpty(ContainerOpenHtmlTag)) ContainerOpenHtmlTag = "<" + ContainerHtmlElementName + ">";
        if (string.IsNullOrEmpty(ContainerCloseHtmlTag)) ContainerCloseHtmlTag = "</" + ContainerHtmlElementName + ">";
      }

    }

149. Example

Project: vsLua
Source File: Grammar.cs
View license
public virtual string GetParseNodeCaption(ParseTreeNode node) {
      if (node.IsError)
        return node.Term.Name + " (Syntax error)";
      if (node.Token != null)
        return node.Token.ToString();
      if(node.Term == null) //special case for initial node pushed into the stack at parser start
        return (node.State != null ? string.Empty : "(State " + node.State.Name + ")"); //  Resources.LabelInitialState;
      var ntTerm = node.Term as NonTerminal;
      if(ntTerm != null && !string.IsNullOrEmpty(ntTerm.NodeCaptionTemplate))
        return ntTerm.GetNodeCaption(node); 
      return node.Term.Name; 
    }

150. Example

View license
[HttpPost]
        public IActionResult Create([FromBody] ServerJob job)
        {
            if (job == null || job.Id != 0 || job.State != ServerState.Waiting ||
                job.Sources.Any(source => string.IsNullOrEmpty(source.Repository)))
            {
                return BadRequest();
            }

            job = _jobs.Add(job);

            Response.Headers["Location"] = $"/jobs/{job.Id}";
            return new StatusCodeResult((int)HttpStatusCode.Accepted);
        }