/// <summary> /// Create user with userName /// </summary> /// <param name="userName"></param> /// <returns></returns> public AspNetUser CreateUser(string userName, IdType idType = IdType.Integer) { var userId = string.Empty; switch (idType) { case IdType.Guid: userId = Guid.NewGuid().ToString(); break; case IdType.Integer: default: userId = GetNextId().ToString(); break; } AspNetUser user = new AspNetUser(); user.Id = userId; user.FirstName = "Test"; user.Surname = "LastName"; user.Email = userName; user.EmailConfirmed = true; user.UserName = userName; model.AspNetUsers.Add(user); return user; }
public TableInfo(string name, string tenantColumn = null, string idColumn = null, IdType idType = IdType.Autoincrement) { Name = name; IdColumn = idColumn; IdType = idType; TenantColumn = tenantColumn; UserIDColumns = new string[0]; DateColumns = new Dictionary<string, bool>(); InsertMethod = InsertMethod.Insert; }
public void Write(XmlWriter writer, IProgress <GexfProgress> progress) { writer.WriteStartElement(XmlElementName); writer.WriteAttributeString(XmlAttibuteNameDefaultEdgeType, DefaultEdgeType.ToString()); writer.WriteAttributeString(XmlAttibuteNameIdType, IdType.ToString()); writer.WriteAttributeString(XmlAttibuteNameMode, Mode.ToString()); _nodeList.Write(writer, progress); _edgeList.Write(writer, progress); writer.WriteEndElement(); }
/// <summary> /// Deletes a record from the Golfer table by GolferId. /// </summary> /// <param name=""></param> public static void Delete(IdType golferId) { // Create and execute the command SqlCommand cmd = GetSqlCommand(CONNECTION_STRING_KEY, "spGolfer_Delete", CommandType.StoredProcedure, COMMAND_TIMEOUT); // Create and append the parameters cmd.Parameters.Add(new SqlParameter("@GolferId", SqlDbType.Int, 0, ParameterDirection.Input, false, 10, 0, "GolferId", DataRowVersion.Proposed, golferId.DBValue)); // Execute the query and return the result cmd.ExecuteNonQuery(); cmd.Connection.Close(); }
public int CompareTo(IStructureId other) { if (other.IdType != IdType) { throw new SisoDbException(ExceptionMessages.StructureId_CompareTo_DifferentIdTypes); } if (Equals(other)) { return(0); } if (IdType == StructureIdTypes.Identity) { var x = (int?)Value; var y = (int?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } if (IdType == StructureIdTypes.BigIdentity) { var x = (long?)Value; var y = (long?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } if (IdType.IsGuid()) { var x = (Guid?)Value; var y = (Guid?)other.Value; if (x.HasValue && y.HasValue) { return(x.Value.CompareTo(y.Value)); } return(x.HasValue ? -1 : 1); } return(Sys.StringComparer.Compare(Value.ToString(), other.Value.ToString())); }
public string IdForString(string s, IdType t) { StringPool sp = m_pools[(int)t]; bool newString; string id = sp.IdForString(s, out newString); if (newString) { m_factorySetup.Add(string.Format("CComBSTR {0}(OLESTR(\"{1}\"));", id, s)); } return(id); }
public static NodeId CreateID(object nodeId, ushort namespaceIndex, IdType nodeIdType) { if (nodeIdType == IdType.Numeric) { return(new NodeId(Convert.ToUInt32(nodeId), namespaceIndex)); } else { return(new NodeId((String)nodeId, namespaceIndex)); } //TODO: Add all other ID Types: GUID, etc.. }
/// <summary> /// 返回实例Id (线程安全) /// </summary> /// <param name="type"></param> /// <returns></returns> public static Int64 getId(IdType type) { lock (mLock) { Int64 startId; if (!mIds.TryGetValue(type, out startId)) { mIds.Add(type, Default_ID_Begin); } return((Int64)((((UInt64)type & 0x00000000000000FF) << 56) | ((UInt64)((mIds[type]++) & 0x00FFFFFFFFFFFFFF)))); } }
public void GivenMethodCallExpressionWithMatchingExpressionAndArgumentsWhenAreEquivalentCalledThenShouldReturnTrue() { var sourceMethod = typeof(IdType).MethodWithNameAndParameterCount( nameof(IdType.Echo), 1); var expr = new IdType().AsParameterExpression(); var source = Expression.Call( expr, sourceMethod, "1".AsConstantExpression()); var target = Expression.Call( expr, sourceMethod, "1".AsConstantExpression()); Assert.True(eq.AreEquivalent(source, target)); }
public override IdGenerator Open(File fileName, int grabSize, IdType idType, System.Func <long> highId, long maxId) { IdGenerator generator = Generators[idType]; if (generator == null) { IdTypeConfiguration idTypeConfiguration = IdTypeConfigurationProvider.getIdTypeConfiguration(idType); generator = new EphemeralIdGenerator(idType, idTypeConfiguration); Generators[idType] = generator; } return(generator); }
public void GivenConfiguredWhenGetServiceCalledWithNonArgumentWithResolveSetThenShouldReturnWithArgument() { var source = new Services(); var param = new IdType(); source.RegisterServices(registration => source.Register <StringWrapper, StringWrapper>()); var target = source.GetService <StringWrapper>(param); Assert.NotNull(target); Assert.Equal(target.Id, param.Id); }
public void GivenRegisteredSingletonWhenSameTypeRegisteredWithSingletonThenShouldReplaceInstance() { var source = new Services(); var id1 = new IdType(); var id2 = new IdType(); source.RegisterServices(register => register.RegisterSingleton(id1) .RegisterSingleton(id2)); Assert.NotSame(id1, source.GetService <IdType>()); Assert.Same(id2, source.GetService <IdType>()); }
private bool ReplicateIdAllocationRequest(IdType idType, ReplicatedIdAllocationRequest idAllocationRequest) { try { return(( bool? )_replicator.replicate(idAllocationRequest, true).get().Value); } catch (Exception e) { _log.warn(format("Failed to acquire id range for idType %s", idType), e); throw new IdGenerationException(e); } }
private static Header ParseRelationshipHeader(Args args, IdType idType, Extractors extractors, Groups groups) { string definition = args.Get("relationship-header", null); if (string.ReferenceEquals(definition, null)) { return(DataGeneratorInput.bareboneRelationshipHeader(idType, extractors)); } Configuration config = Configuration.COMMAS; return(DataFactories.defaultFormatRelationshipFileHeader().create(Seeker(definition, config), config, idType, groups)); }
/// <summary> /// Updates the identifier. /// </summary> internal void SetIdentifier(IdType idType, object value) { m_identifierType = idType; switch (idType) { case IdType.Opaque_3: throw new NotImplementedException(" m_identifier = Utils.Clone(value);"); default: m_identifierPart = value; break; } }
public Vendor(VendorData data) { // initialize the internal state SetInitialState(); // copy the applicable properties, if they are valid UpdateInternalState(data); // insert new record IdType id = VendorDAO.Insert(internalState); internalState.VendorID = id; }
public static void Delete(IdType eventId) { // Create and execute the command string sql = "Delete From " + TABLE; WhereClause w = new WhereClause(); w.And("Event_Id", eventId.DBValue); sql += w.FormatSql(); SqlCommand cmd = GetSqlCommand(DatabaseEnum.ORDERDB, sql, CommandType.Text, COMMAND_TIMEOUT); // Execute the query and return the result cmd.ExecuteNonQuery(); }
private IdGenerator OpenGenerator(File file, int grabSize, IdType idType, System.Func <long> highId, long maxId, bool aggressiveReuse) { ReplicatedIdGenerator other = _generators[idType]; if (other != null) { other.Dispose(); } ReplicatedIdGenerator replicatedIdGenerator = new ReplicatedIdGenerator(_fs, file, idType, highId, _idRangeAcquirer, _logProvider, grabSize, aggressiveReuse); _generators[idType] = replicatedIdGenerator; return(replicatedIdGenerator); }
private static void AssertIdTypesToReuseDisallows(IdType type, params IdType[] otherTypes) { try { Config config = ConfigWithIdTypes(type, otherTypes); config.Get(idTypesToReuse); fail("Exception expected"); } catch (Exception e) { assertThat(e, instanceOf(typeof(InvalidSettingException))); } }
public async void Update(IdType opt, string surname, string newMessengerId) { string sql = "UPDATE Students SET " + opt.ToString() + " = @messengerId WHERE Surname = @Surname"; SqlCommand cmd = connection.CreateCommand(); cmd.CommandText = sql; cmd.Parameters.Add("@Surname", System.Data.SqlDbType.NVarChar).Value = surname; cmd.Parameters.Add("@messengerId", System.Data.SqlDbType.NVarChar).Value = newMessengerId; await cmd.ExecuteNonQueryAsync(); }
public IActionResult GetById(IdType id) { id = new IdType(22); var item = _userService.GetOne(id); if (item == null) { Log.Error("GetById({ ID}) NOT FOUND", id); return(NotFound()); } return(Ok(item)); }
public static void Delete(IdType calendarsItemsLocationsID) { // Create and execute the command string sql = "Delete From " + TABLE; WhereClause w = new WhereClause(); w.And("CalendarsItemsLocationsID", calendarsItemsLocationsID.DBValue); sql += w.FormatSql(); SqlCommand cmd = GetSqlCommand(DatabaseEnum.INTRANET, sql, CommandType.Text, COMMAND_TIMEOUT); // Execute the query and return the result cmd.ExecuteNonQuery(); }
/// <summary> /// To Claim Types extensions. Gets the ClaimTypes for a specified IdType /// </summary> /// <param name="idType"></param> /// <returns>ClaimTypes</returns> public static string ToClaimTypes(this IdType idType) { var claimTypes = IdTypeHelpers.ClaimTypes; if (claimTypes == null || !claimTypes.Any()) { IdTypeHelpers.LoadClaimTypes(); claimTypes = IdTypeHelpers.ClaimTypes; } return(claimTypes[idType.ToString()]); }
//Returns unique online user ID for this player public static void GetUserID(out IdType id_type, out string id) { #if UNITY_XBOXONE // Xbox One does not want XUID stored in a database, so we are going to treat Xbox One like PC without Steam/GOG. Old method is // commented out below for comparison. /* * id_type = IdType.XBLive; * id = XboxOneManager.GetActiveUserXuid(); */ id_type = IdType.Local; id = Player.Mp_user_id; if (string.IsNullOrEmpty(id)) { id = Guid.NewGuid().ToString(); Player.Mp_user_id = id; PilotManager.SavePreferences(); // save prefs, which stores Player.Mp_user_id in the profile } return; #elif UNITY_PS4 id_type = IdType.PSN; id = PS4Manager.UserId.ToString(); return; #else if (CloudProvider == CloudProviders.Steam) { id_type = IdType.Steam; id = Steamworks.SteamUser.GetSteamID().ToString(); return; #if !UNITY_STANDALONE_LINUX } else if (CloudProvider == CloudProviders.Galaxy) { id_type = IdType.Galaxy; id = Galaxy.Api.GalaxyInstance.User().GetGalaxyID().ToString(); return; #endif } else { id_type = IdType.Local; id = PlayerPrefs.GetString("UserID"); if (id == "") { id = Guid.NewGuid().ToString(); PlayerPrefs.SetString("UserID", id); } } #endif }
public ParsedId GetInfo(string guId, IdType type) { ParsedId res = null; switch (type) { case (IdType.Room): //ищем комнату res = (from h in context.Room where h.ROOMGUID == guId select new ParsedId() { id = h.ROOMGUID, level = -1, name = h.ROOMNUMBER, prevId = h.HOUSEGUID, type = IdType.Room }).ToList().First(); break; case (IdType.House): //ищем дом res = (from h in context.House where h.HOUSEGUID == guId select new ParsedId() { id = guId, level = -1, name = h.HOUSENUM, prevId = h.AOGUID, type = IdType.House } ).ToList().First(); break; case (IdType.Object): res = (from o in context.Object where o.AOGUID == guId && o.ACTSTATUS == 1 select new ParsedId() { id = guId, level = o.AOLEVEL, name = o.FORMALNAME, shortName = o.SHORTNAME, prevId = o.PARENTGUID, type = IdType.Object }).ToList().First(); break; } return(res); }
private void ParseChunk() { if (CkId == IdType.FRM8) { FormTyped = ReadId(); if (DisplayInfo) { Console.WriteLine("FRM8: Form type: " + FormTyped); } } else if (CkId == IdType.FVER) { Version = _inStream.ReadByte().ToString(CultureInfo.InvariantCulture) + "." + _inStream.ReadByte().ToString(CultureInfo.InvariantCulture) + "." + _inStream.ReadByte().ToString(CultureInfo.InvariantCulture) + "." + _inStream.ReadByte().ToString(CultureInfo.InvariantCulture); if (DisplayInfo) { Console.WriteLine("File version: {0}", Version); } } else if (CkId == IdType.PROP) { var id = ReadId(); if (id != IdType.SND) { throw new Exception("Invalid property chunk in DSDIFF file"); } ParseProperties(); } else if (CkId == IdType.COMT) { ParseComments(); } else if (CkId == IdType.DIIN) { ParseMasterInfo(); } else if (CkId == IdType.ID3) { ID3 = ReadBytes((int)CkDataSize); if (DisplayInfo) { Console.Write("ID3 tag was readed, len: " + CkDataSize); } } }
public TeamData this[IdType teamId] { get { foreach (TeamData o in List) { if (o.TeamId.Equals(teamId)) { return(o); } } // not found return(null); } }
protected IWebApiResponse RetByIdsLogic(int[] ids, IdType type) { var response = new WebApiResponse <SearchResult>(new SearchResult()); try { if (ids == null) { throw new HttpResponseException(HttpStatusCode.NotAcceptable); } List <PeinInfo> rr = new List <PeinInfo>(); if (type == IdType.Id) { rr = BL.GetPeinItemByIds(ids); } else { rr = BL.GetPeinItemByRecordIds(ids); } var sr = new SearchResult { Result = FormatDetailUrl(rr) }; if (rr.Any()) { int count = rr.Count(); sr.Info = new ResultInfo { TotalFound = count, Showing = count, StartRow = 0, EndRow = count }; } else { sr.Info = new ResultInfo { Text = "No matches found" }; } response = new WebApiResponse <SearchResult>(sr); } catch (Exception ex) { response.ApiSuccess = false; response.ApiStackTrace = ex.Message; } return(response); }
public ParticipantData this[IdType participantId] { get { foreach (ParticipantData o in List) { if (o.ParticipantId.Equals(participantId)) { return(o); } } // not found return(null); } }
public static NewsArticlesLocationsData Load(IdType newsArticlesLocationsID) { WhereClause w = new WhereClause(); w.And("NewsArticlesLocationsID", newsArticlesLocationsID.DBValue); SqlDataReader dataReader = GetListReader(DatabaseEnum.INTRANET, TABLE, w, null, true); if (!dataReader.Read()) { dataReader.Close(); throw new FinderException("Load found no rows for NewsArticlesLocations."); } NewsArticlesLocationsData data = GetDataObjectFromReader(dataReader); dataReader.Close(); return data; }
public TournamentFeeData this[IdType tournamentFeeId] { get { foreach (TournamentFeeData o in List) { if (o.TournamentFeeId.Equals(tournamentFeeId)) { return(o); } } // not found return(null); } }
public override IdGenerator open(File fileName, int grabSize, IdType idType, System.Func <long> highId, long maxId) { if (idType == IdType.LABEL_TOKEN) { IdGenerator generator = generators.get(idType); if (generator == null) { IdTypeConfiguration idTypeConfiguration = idTypeConfigurationProvider.getIdTypeConfiguration(idType); generator = new EphemeralIdGeneratorAnonymousInnerClass(this, idType, idTypeConfiguration); generators.put(idType, generator); } return(generator); } return(base.open(fileName, grabSize, idType, () => long.MaxValue, long.MaxValue)); }
// For root level document id generation; used during the class map registration of data model public MongoIntIdGenerator(IdType idType) : this(idType, null) { }
// For embedded document id generation; used during MongoCommand execution public MongoIntIdGenerator(IdType idType, MongoDatabase mongoDb) { this.idType = idType; this.mongoDb = mongoDb; }
public IIdGenerator Create(IdType type) { return new MongoIntIdGenerator(type, this.mongoDatabase); }
/// <summary> /// Search for and return the title and filename for the given ID /// </summary> /// <param name="idType">The ID type.</param> /// <param name="id">The ID of the item for which to get information.</param> /// <param name="title">On return, contains the title of the item if found.</param> /// <param name="filename">On return, contains the filename of the item if found.</param> /// <param name="relativePath">On return, contains the topic file path relative to its project folder. /// This can be used for display as it is typically much shorter than the full path.</param> /// <returns>True if successful, false if not</returns> public bool GetInfoFor(IdType idType, string id, out string title, out string filename, out string relativePath) { title = filename = relativePath = "(Not found)"; try { if(!this.DetermineCurrentSolutionAndProjects()) { filename = relativePath = "Unable to determine current solution and/or projects"; return false; } // Topic IDs must be matched to files so a separate cache is maintained for them if(idType == IdType.Link) { bool found = TopicIdCache.Instance.GetTopicInfo(id, out title, out filename, out relativePath); // Tell the user if still indexing. We may not have a filename yet. if(TopicIdCache.Instance.IsIndexingTopics) { filename = relativePath = "Topic ID cache is being built. Try again in a few seconds."; found = false; } else if(!found) { // Not found, try reindexing to update the info TopicIdCache.Instance.SetCurrentSolutionAndProjects(currentSolution.FullName, shfbProjects); // If it exists, we should at least have a title at this point so go get it TopicIdCache.Instance.GetTopicInfo(id, out title, out filename, out relativePath); filename = relativePath = "Topic ID cache is being built. Try again in a few seconds."; } return found; } if(idType == IdType.Image) foreach(var currentProject in shfbProjects) { var image = currentProject.GetItems("Image").FirstOrDefault(pi => pi.Metadata.Any(m => m.Name == "ImageId" && m.EvaluatedValue.Equals(id, StringComparison.OrdinalIgnoreCase))); if(image != null) { var altText = image.Metadata.FirstOrDefault(m => m.Name == "AlternateText"); if(altText != null && !String.IsNullOrWhiteSpace(altText.EvaluatedValue)) title = altText.EvaluatedValue; else title = "(Not set)"; filename = relativePath = image.EvaluatedInclude; return true; } } } catch(Exception ex) { // Ignore exceptions, we'll just fail the search System.Diagnostics.Debug.WriteLine(ex); } return false; }
//===================================================================== /// <summary> /// Search for and go to the definition of the given member ID /// </summary> /// <param name="idType">The ID type</param> /// <param name="id">The ID of the item for which to open a file</param> /// <returns>True if successful, false if not</returns> public bool OpenFileFor(IdType idType, string id) { try { if(!this.DetermineCurrentSolutionAndProjects()) return false; // Topic IDs must be matched to files so a separate cache is maintained for them if(idType == IdType.Link) { // Ignore the request if still indexing if(TopicIdCache.Instance.IsIndexingTopics) return true; string topicTitle, topicFilename, relativePath; if(!TopicIdCache.Instance.GetTopicInfo(id, out topicTitle, out topicFilename, out relativePath)) { // Not found, try reindexing to update the info TopicIdCache.Instance.SetCurrentSolutionAndProjects(currentSolution.FullName, shfbProjects); return true; } var item = currentSolution.FindProjectItem(topicFilename); if(item != null) { var window = item.Open(); if(window != null) { window.Activate(); return true; } } return false; } // All other files are few an are searched for when requested foreach(var currentProject in shfbProjects) switch(idType) { case IdType.CodeReference: if(this.OpenCodeSnippetFile(currentProject, id)) return true; break; case IdType.Image: var image = currentProject.GetItems("Image").FirstOrDefault(pi => pi.Metadata.Any(m => m.Name == "ImageId" && m.EvaluatedValue.Equals(id, StringComparison.OrdinalIgnoreCase))); if(image != null) { var item = currentSolution.FindProjectItem(image.EvaluatedInclude); if(item != null) { var window = item.Open(); if(window != null) { window.Activate(); return true; } } } break; case IdType.Token: if(this.OpenTokenFile(currentProject, id)) return true; break; default: // Unknown break; } } catch(Exception ex) { // Ignore exceptions, we'll just fail the search System.Diagnostics.Debug.WriteLine(ex); } return false; }
public string Get(string id, IdType type) { string endpoint = _config.Endpoint + ENTITY_COMMAND; _restClient.EndPoint = endpoint; // Determine which authentication method to use if(string.IsNullOrEmpty(_config.AccessToken)) { // use client id/secret if(string.IsNullOrEmpty(_config.ClientId) || string.IsNullOrEmpty(_config.ClientSecret)) { throw new ApplicationException("No credentials were provided. You must either provide a Client ID and Secret or an access token"); } _restClient.AddParameter("client_id", _config.ClientId); _restClient.AddParameter("client_secret", _config.ClientSecret); } else { _restClient.AddParameter("access_token", _config.AccessToken); } // id _restClient.AddParameter(type.ToString().ToLower(), id); // attribute_name // attributes // created // last updated string jsonResult = _restClient.MakeRequest(); JumpResult jr = (JumpResult)DeserializeResult(jsonResult); return jr.result; }