public virtual void SetIdAndProps(SemiSymbol other) { this.id = other.id; this.IsNew = false; this.toStr = this.Key; this.Name = other.Name; if (this.Modified != ModifiedState.Sealed) { this.Modified = ModifiedState.Sealed; } }
/// <summary> /// Similar methods of inheritors will be automatically called by Signum.MSBuildTask using AutoInitiAttribute /// </summary> public SemiSymbol(Type declaringType, string fieldName) { this.fieldInfo = declaringType.GetField(fieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (this.fieldInfo == null) { throw new InvalidOperationException(string.Format("No field with name {0} found in {1}", fieldName, declaringType.Name)); } this.Key = declaringType.Name + "." + fieldName; this.Name = fieldName; try { Symbols.GetOrCreate(this.GetType()).Add(this.Key, this); } catch (Exception e) when(StartParameters.IgnoredCodeErrors != null) { //Could happend if Dynamic code has a duplicated name this.fieldInfo = null; this.Key = null; StartParameters.IgnoredCodeErrors.Add(e); return; } var dic = FromDatabase.TryGetC(this.GetType()); if (dic != null) { SemiSymbol semiS = dic.TryGetC(this.Key); if (semiS != null) { this.SetIdAndProps(semiS); } } }