public static IEnumerable<MetaType> Repeat(int count, MetaType toRepeat) { for (int i = 0; i < count; i++) { yield return toRepeat; } }
public static void Clear() { cachedType = null; cachedClass = null; cachedVariable = null; cachedMethod = null; }
public ActionResult edit(MetaType type, string value) { return View("create", MetaItem.SelectById(new MetaItemKey { Type = type, Value = value })); }
/// <summary> /// Resolves a MetaType instance from a particular document into CLR Type, i.e. an obsolete class named "ABC" may be resolved into /// newer class "ABCX" /// </summary> public virtual Type ResolveType(MetaType metaType) { if (metaType.__CLRType!=null) return metaType.__CLRType; var result = Type.GetType(metaType.AssemblyQualifiedName, true, false); metaType.__CLRType = result; return result; }
public ValueList() { InitializeComponent(); this.owner = null; this.repository = null; this.type = null; this.listValues = null; this.Enabled = false; this.refreshing = false; }
public MetaInfo(int metaId, int objId, MetaType type, string title, string metaKeywords, string metaDescription, string h1) { MetaId = metaId; ObjId = objId; Type = type; Title = title; MetaKeywords = metaKeywords; MetaDescription = metaDescription; H1 = h1; }
/// <summary> /// Constructor that takes the metadata context, a metadata type and a parent custom type descriptor /// </summary> /// <param name="typeDescriptionContext">The <see cref="LinqToSqlTypeDescriptionContext"/> context.</param> /// <param name="metaType">The <see cref="MetaType"/> type.</param> /// <param name="parent">The parent custom type descriptor.</param> public LinqToSqlTypeDescriptor(LinqToSqlTypeDescriptionContext typeDescriptionContext, MetaType metaType, ICustomTypeDescriptor parent) : base(parent) { this._typeDescriptionContext = typeDescriptionContext; this._metaType = metaType; // if any FK member of any association is also part of the primary key, then the key cannot be marked // Editable(false) this._keyIsEditable = this._metaType.Associations.Any(p => p.IsForeignKey && p.ThisKey.Any(q => q.IsPrimaryKey)); }
public VariableList() { InitializeComponent(); this.owner = null; this.repository = null; this.type = null; this.value = null; this.valueControls = new List<Control>(); this.refreshing = false; this.Enabled = false; }
public ActionResult create(MetaType type, string value) { return View(new MetaItem { Id = new MetaItemKey { Type = type, Value = value } }); }
public ValueDictionary() { InitializeComponent(); this.owner = null; this.repository = null; this.type1 = null; this.type2 = null; this.dictionaryKeys = null; this.dictionaryValues = null; this.Enabled = false; this.refreshing = false; }
public MetaTextBuilder(MetaType type, string text) { this.type = type; if (text != null) { this.text = text; } else { this.text = string.Empty; } }
private static MetaData ParseThread(string filename, MetaType type) { if (!File.Exists(filename)) throw new MetaParseException("File not found: {0}", filename); MetaData meta = new MetaData(); meta.Type = type; meta.Path = filename; meta.Data = new Dictionary<MetaKey, object>(); meta.Data[MetaKey.FileName] = Path.GetFileName(filename); meta.Data[MetaKey.OriginalName] = meta.Data[MetaKey.FileName]; meta.Data[MetaKey.Size] = GetFileSize(filename); meta.Data[MetaKey.DateCreated] = File.GetCreationTime(filename); meta.Data[MetaKey.DateModified] = File.GetLastWriteTime(filename); meta.Data[MetaKey.Timestamp] = meta.Data[MetaKey.DateModified]; meta.Data[MetaKey.Tags] = new string[0]; return meta; }
public ManagerInstance(Repository repository, MetaType metaType, MetaValue metaValue, bool nullable = false) { InitializeComponent(); this.repository = repository; this.value = metaValue; this.cbxExists.Checked = (this.value.Instance != null); if (this.value.Type.CategoryType == ECategoryType.Class && this.value.Instance == null) { this.value.Instance = new MetaInstance((MetaClass)metaType); } this.type = metaType; this.vlVariables.SetData(this, this.repository, this.type); this.vlVariables.SetValue(this.value); if (!nullable) { this.cbxExists.Enabled = false; this.cbxExists.Checked = true; } this.RefreshData(); }
public static Dictionary<string, string> GetSpecificVariables(MetaType type, string name, string categoryName = null, string brandName = null) { if (name != null) { switch (type) { case MetaType.Category: return new Dictionary<string, string> { { "#CATEGORY_NAME#", name } }; case MetaType.Product: return new Dictionary<string, string> { { "#PRODUCT_NAME#", name }, { "#CATEGORY_NAME#", categoryName }, { "#BRAND_NAME#", brandName } }; case MetaType.News: return new Dictionary<string, string> { { "#NEWS_NAME#", name } }; case MetaType.Brand: return new Dictionary<string, string> { { "#BRAND_NAME#", name } }; case MetaType.StaticPage: return new Dictionary<string, string> { { "#PAGE_NAME#", name } }; default: return new Dictionary<string, string>(); } } return new Dictionary<string, string>(); }
/// <summary> /// Indicates whether or not a meta message type is a text based type. /// </summary> /// <param name="type"> /// The meta message type to test. /// </param> /// <returns> /// <b>true</b> if the meta message type is a text based type; /// otherwise, <b>false</b>. /// </returns> private bool IsTextType(MetaType type) { if(type == MetaType.Copyright || type == MetaType.CuePoint || type == MetaType.DeviceName || type == MetaType.InstrumentName || type == MetaType.Lyric || type == MetaType.Marker || type == MetaType.ProgramName || type == MetaType.Text || type == MetaType.TrackName) { return true; } else { return false; } }
public string GetValue(MetaType metaType) { var value = this.GetType().GetProperty(metaType.ToString()).GetValue(this, null); return(value.ToString()); }
private Type(IEnumerable<MetaType> parameters) { this.type = MetaType.Vector; this.vectorParameterTypes = parameters.ToArray(); }
internal SqlExpression TypeCase(Type clrType, MetaType rowType, SqlExpression discriminator, IEnumerable <SqlTypeCaseWhen> whens, Expression sourceExpression) => new SqlTypeCase(clrType, TypeProvider.From(clrType), rowType, discriminator, whens, sourceExpression);
} // using xmlWriter /// <summary> /// /// </summary> /// <param name="topElement">the 'Changes' element, to be manipulated</param> /// <param name="command"></param> private static void WriteAddOrReplaceCommandToXml(XElement topElement, SyncMLUpdateBase command) { if (command == null) { return; } bool isBase64 = false; ContactExchangeType contentType = ContactExchangeType.Unknown; bool isAddCommand = false; string commandTypeStr; SyncMLMeta commandMeta = command.Meta; SyncMLItem commandItem = command.ItemCollection[0]; //assuming there is always one item. if (String.IsNullOrEmpty(commandMeta.Content) && (!commandMeta.Xml.HasElements)) { commandMeta = commandItem.Meta; } MetaParser metaParser = new MetaParser(commandMeta.Xml); MetaFormat metaFormat = metaParser.GetMetaFormat(); if (metaFormat != null) { isBase64 = metaFormat.Content == "b64"; } MetaType metaType = metaParser.GetMetaType(); if (metaType == null) { return; //the meta element may be empty, so no need to proceed. } if (metaType.Content == "text/x-s4j-sifc") { contentType = ContactExchangeType.Sifc; } else if ((metaType.Content == "text/x-vcard") || (metaType.Content == "text/vcard")) { contentType = ContactExchangeType.Vcard21; } if (contentType == ContactExchangeType.Unknown) { throw new LocalDataSourceException("expected data is Base64 encoded SIF-C or vCard"); } isAddCommand = command is SyncMLAdd; commandTypeStr = isAddCommand ? "New" : "Update"; //Assuming there will be only one item. string id; if (isAddCommand) { id = commandItem.Source.LocURI.Content; } else { id = commandItem.Target.LocURI.Content; } XElement cItem = new XElement("C", new XAttribute("ID", id)); XElement changItem = new XElement(commandTypeStr, cItem); topElement.Add(changItem); switch (contentType) { case ContactExchangeType.Sifc: // do not need to check isBase64, because it must be cItem.Add(XElement.Parse(Utility.ConvertFromBase64(commandItem.Data.Content))); break; case ContactExchangeType.Vcard21: XElement sifcXml; if (isBase64) { sifcXml = VCardSIFC.ConvertVCardToSifCXml(VCardReader.ParseText( Utility.ConvertFromBase64(commandItem.Data.Content))); } else { sifcXml = VCardSIFC.ConvertVCardToSifCXml(VCardReader.ParseText(commandItem.Data.Content)); } cItem.Add(sifcXml); break; default: throw new LocalDataSourceException("Can not create stream from command Data."); } }
internal SqlExpression TranslateEquals(SqlBinary expr) { System.Diagnostics.Debug.Assert( expr.NodeType == SqlNodeType.EQ || expr.NodeType == SqlNodeType.NE || expr.NodeType == SqlNodeType.EQ2V || expr.NodeType == SqlNodeType.NE2V); SqlExpression eLeft = expr.Left; SqlExpression eRight = expr.Right; if (eRight.NodeType == SqlNodeType.Element) { SqlSubSelect sub = (SqlSubSelect)eRight; SqlAlias alias = new SqlAlias(sub.Select); SqlAliasRef aref = new SqlAliasRef(alias); SqlSelect select = new SqlSelect(aref, alias, expr.SourceExpression); select.Where = sql.Binary(expr.NodeType, sql.DoNotVisitExpression(eLeft), aref); return(sql.SubSelect(SqlNodeType.Exists, select)); } else if (eLeft.NodeType == SqlNodeType.Element) { SqlSubSelect sub = (SqlSubSelect)eLeft; SqlAlias alias = new SqlAlias(sub.Select); SqlAliasRef aref = new SqlAliasRef(alias); SqlSelect select = new SqlSelect(aref, alias, expr.SourceExpression); select.Where = sql.Binary(expr.NodeType, sql.DoNotVisitExpression(eRight), aref); return(sql.SubSelect(SqlNodeType.Exists, select)); } MetaType mtLeft = TypeSource.GetSourceMetaType(eLeft, this.services.Model); MetaType mtRight = TypeSource.GetSourceMetaType(eRight, this.services.Model); if (eLeft.NodeType == SqlNodeType.TypeCase) { eLeft = BestIdentityNode((SqlTypeCase)eLeft); } if (eRight.NodeType == SqlNodeType.TypeCase) { eRight = BestIdentityNode((SqlTypeCase)eRight); } if (mtLeft.IsEntity && mtRight.IsEntity && mtLeft.Table != mtRight.Table) { throw Error.CannotCompareItemsAssociatedWithDifferentTable(); } // do simple or no translation for non-structural types if (!mtLeft.IsEntity && !mtRight.IsEntity && (eLeft.NodeType != SqlNodeType.New || eLeft.SqlType.CanBeColumn) && (eRight.NodeType != SqlNodeType.New || eRight.SqlType.CanBeColumn)) { if (expr.NodeType == SqlNodeType.EQ2V || expr.NodeType == SqlNodeType.NE2V) { return(this.TranslateEqualsOp(expr.NodeType, sql.DoNotVisitExpression(expr.Left), sql.DoNotVisitExpression(expr.Right), false)); } return(expr); } // If the two types are not comparable, we return the predicate "1=0". if ((mtLeft != mtRight) && (mtLeft.InheritanceRoot != mtRight.InheritanceRoot)) { return(sql.Binary(SqlNodeType.EQ, sql.ValueFromObject(0, expr.SourceExpression), sql.ValueFromObject(1, expr.SourceExpression))); } List <SqlExpression> exprs1; List <SqlExpression> exprs2; SqlLink link1 = eLeft as SqlLink; if (link1 != null && link1.Member.IsAssociation && link1.Member.Association.IsForeignKey) { exprs1 = link1.KeyExpressions; } else { exprs1 = this.GetIdentityExpressions(mtLeft, sql.DoNotVisitExpression(eLeft)); } SqlLink link2 = eRight as SqlLink; if (link2 != null && link2.Member.IsAssociation && link2.Member.Association.IsForeignKey) { exprs2 = link2.KeyExpressions; } else { exprs2 = this.GetIdentityExpressions(mtRight, sql.DoNotVisitExpression(eRight)); } System.Diagnostics.Debug.Assert(exprs1.Count > 0); System.Diagnostics.Debug.Assert(exprs2.Count > 0); System.Diagnostics.Debug.Assert(exprs1.Count == exprs2.Count); SqlExpression exp = null; SqlNodeType eqKind = (expr.NodeType == SqlNodeType.EQ2V || expr.NodeType == SqlNodeType.NE2V) ? SqlNodeType.EQ2V : SqlNodeType.EQ; for (int i = 0, n = exprs1.Count; i < n; i++) { SqlExpression eq = this.TranslateEqualsOp(eqKind, exprs1[i], exprs2[i], !mtLeft.IsEntity); if (exp == null) { exp = eq; } else { exp = sql.Binary(SqlNodeType.And, exp, eq); } } if (expr.NodeType == SqlNodeType.NE || expr.NodeType == SqlNodeType.NE2V) { exp = sql.Unary(SqlNodeType.Not, exp, exp.SourceExpression); } return(exp); }
public virtual void ApplyDefaultBehaviour(MetaType metaType) { var type = metaType.Type; Type baseType = metaType.GetBaseType(); if (baseType != null && CanAutoAddType(baseType) && MetaType.CanHaveSubType(baseType)) { Model.FindOrAddAuto(baseType, true, false, false); } try { AttributeFamily family; TypeState mapped; { AttributeMap[] typeAttribs = AttributeMap.Create(Model, type, false); family = GetContractFamily(type, typeAttribs); mapped = TypeMapper.Map( new TypeArgsValue(type, typeAttribs, AcceptableAttributes, Model) { Family = family, ImplicitFallbackMode = ImplicitFallbackMode, }); foreach (var candidate in mapped.DerivedTypes) { if (metaType.IsValidSubType(candidate.Type)) { metaType.AddSubType(candidate.Tag, candidate.Type); } } metaType.ReplaceClientSettings(mapped.SettingsValue); } var partialMembers = mapped.PartialMembers; int dataMemberOffset = mapped.DataMemberOffset; int implicitFirstTag = mapped.ImplicitFirstTag; bool inferTagByName = mapped.InferTagByName; ImplicitFieldsMode implicitMode = mapped.ImplicitFields; family = mapped.Input.Family; MethodInfo[] callbacks = null; var members = new List <MappedMember>(); bool isEnum = Helpers.IsEnum(type); #if WINRT System.Collections.Generic.IEnumerable <MemberInfo> foundList; if (isEnum) { foundList = type.GetRuntimeFields().Where(x => x.IsStatic && x.IsPublic); } else { System.Collections.Generic.List <MemberInfo> list = new System.Collections.Generic.List <MemberInfo>(); foreach (PropertyInfo prop in type.GetRuntimeProperties()) { MethodInfo getter = Helpers.GetGetMethod(prop, false, false); if (getter != null && !getter.IsStatic) { list.Add(prop); } } foreach (FieldInfo fld in type.GetRuntimeFields()) { if (fld.IsPublic && !fld.IsStatic) { list.Add(fld); } } foreach (MethodInfo mthd in type.GetRuntimeMethods()) { if (mthd.IsPublic && !mthd.IsStatic) { list.Add(mthd); } } foundList = list; } #else MemberInfo[] foundList = type.GetMembers(isEnum ? BindingFlags.Public | BindingFlags.Static : BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (isEnum) { foundList = foundList.Where(x => x is FieldInfo).ToArray(); } #endif foreach (MemberInfo member in foundList) { if (member.DeclaringType != type) { continue; } var map = AttributeMap.Create(Model, member, true); { var args = new MemberArgsValue(member, map, AcceptableAttributes, Model) { DataMemberOffset = dataMemberOffset, Family = family, InferTagByName = inferTagByName, PartialMembers = partialMembers, IsEnumValueMember = isEnum }; PropertyInfo property; FieldInfo field; if ((property = member as PropertyInfo) != null) { bool isPublic = Helpers.GetGetMethod(property, false, false) != null; bool canBeMapped = isPublic || Helpers.GetGetMethod(property, true, true) != null; if (canBeMapped && (!mapped.ImplicitOnlyWriteable || Helpers.CheckIfPropertyWritable ( Model, property, implicitMode == ImplicitFieldsMode.AllProperties || implicitMode == ImplicitFieldsMode.AllFieldsAndProperties, false))) { switch (implicitMode) { case ImplicitFieldsMode.AllProperties: args.IsForced = true; break; case ImplicitFieldsMode.PublicProperties: if (isPublic) { args.IsForced = true; } break; case ImplicitFieldsMode.PublicFieldsAndProperties: if (isPublic) { args.IsForced = true; } break; case ImplicitFieldsMode.AllFieldsAndProperties: args.IsForced = true; break; } } var r = ApplyDefaultBehaviour_AddMembers(args); if (r != null) { if (!canBeMapped) { throw new MemberAccessException("Property " + property + " should be readable to be mapped."); } members.Add(r); } } else if ((field = member as FieldInfo) != null) { bool isPublic = field.IsPublic; if (!args.IsEnumValueMember) { switch (implicitMode) { case ImplicitFieldsMode.AllFields: args.IsForced = true; break; case ImplicitFieldsMode.PublicFields: if (isPublic) { args.IsForced = true; } break; case ImplicitFieldsMode.PublicFieldsAndProperties: if (isPublic) { args.IsForced = true; } break; case ImplicitFieldsMode.AllFieldsAndProperties: args.IsForced = true; break; } } var r = ApplyDefaultBehaviour_AddMembers(args); if (r != null) { members.Add(r); } } } MethodInfo method; if ((method = member as MethodInfo) != null) { AttributeMap[] memberAttribs = AttributeMap.Create(Model, method, false); if (memberAttribs != null && memberAttribs.Length > 0) { const int max = 11; if (CanUse(AttributeType.ProtoBuf)) { CheckForCallback(method, memberAttribs, "ProtoBuf.ProtoBeforeSerializationAttribute", ref callbacks, 0, max); CheckForCallback(method, memberAttribs, "ProtoBuf.ProtoAfterSerializationAttribute", ref callbacks, 1, max); CheckForCallback(method, memberAttribs, "ProtoBuf.ProtoBeforeDeserializationAttribute", ref callbacks, 2, max); CheckForCallback(method, memberAttribs, "ProtoBuf.ProtoAfterDeserializationAttribute", ref callbacks, 3, max); } CheckForCallback(method, memberAttribs, "System.Runtime.Serialization.OnSerializingAttribute", ref callbacks, 4, max); CheckForCallback(method, memberAttribs, "System.Runtime.Serialization.OnSerializedAttribute", ref callbacks, 5, max); CheckForCallback(method, memberAttribs, "System.Runtime.Serialization.OnDeserializingAttribute", ref callbacks, 6, max); CheckForCallback(method, memberAttribs, "System.Runtime.Serialization.OnDeserializedAttribute", ref callbacks, 7, max); if (CanUse(AttributeType.Aqla)) { CheckForCallback(method, memberAttribs, "AqlaSerializer.BeforeSerializationCallbackAttribute", ref callbacks, 8, max); CheckForCallback(method, memberAttribs, "AqlaSerializer.AfterSerializationCallbackAttribute", ref callbacks, 9, max); CheckForCallback(method, memberAttribs, "AqlaSerializer.BeforeDeserializationCallbackAttribute", ref callbacks, 10, max); CheckForCallback(method, memberAttribs, "AqlaSerializer.AfterDeserializationCallbackAttribute", ref callbacks, 11, max); } } } } if (inferTagByName || implicitMode != ImplicitFieldsMode.None) { members.Sort(); foreach (var member in members) { if (!member.MappingState.TagIsPinned) // if ProtoMember etc sets a tag, we'll trust it { member.Tag = -1; } } } foreach (var member in members.OrderBy(m => m.MappingState.TagIsPinned ? 0 : 1)) { ApplyDefaultBehaviour(metaType, member, (inferTagByName || implicitMode != ImplicitFieldsMode.None) ? (int?)implicitFirstTag : null); } if (callbacks != null) { metaType.SetCallbacks(Coalesce(callbacks, 0, 4, 8), Coalesce(callbacks, 1, 5, 9), Coalesce(callbacks, 2, 6, 10), Coalesce(callbacks, 3, 7, 11)); } if (!DisableAutoAddingMemberTypes) { foreach (var member in members) { if (!member.MappingState.Input.IsEnumValueMember) { Type memberType = Helpers.GetMemberType(member.Member); memberType = Helpers.GetNullableUnderlyingType(memberType) ?? memberType; if (memberType.IsArray) { memberType = memberType.GetElementType(); } memberType = TypeModel.GetListItemType(Model, memberType) ?? memberType; if (memberType == null) { continue; } if (CanAutoAddType(memberType)) { Model.FindOrAddAuto(memberType, true, false, false); } } } } if (UseLegacyTupleFields) { foreach (ValueMember vm in metaType.GetTupleFields()) { vm.SetSettings(x => x.V.DefaultsMode = MemberDefaultsMode.LegacyTuple); } } } finally { if (baseType != null && GetContractFamily(baseType) != AttributeFamily.None) { if (Model.FindWithoutAdd(baseType) != null) { MetaType baseMeta = Model[baseType]; // we can't add to frozen base type // but this is not always an error // e.g. dynamic member of base type doesn't need registered subtype if (!baseMeta.IsFrozen && !DisableAutoRegisteringSubtypes && !baseMeta.IsList && baseMeta.IsValidSubType(type) && CanAutoAddType(baseType)) { baseMeta.AddSubType(baseMeta.GetNextFreeFieldNumber(AutoRegisteringSubtypesFirstTag), type); } } } } }
public AttributedAssociationMetaDataMember(MemberInfo member, AssociationAttribute attribute, MetaType declaringType) : base(member, declaringType, attribute) { associationAttribute = attribute; }
private static bool IsBasedOn(MetaType mt, Type t) { return(mt.Type.FullName.Contains(t.Name)); // to refactor, as it's blach magic knowing that BuildType uses name. }
/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns>localId=serverId pair</returns> private string ApplyAddOrReplaceCommand(SyncMLUpdateBase command) { if (command == null) { return(null); } bool isBase64 = false; bool isAddCommand = false; SyncMLMeta commandMeta = command.Meta; SyncMLItem commandItem = command.ItemCollection[0]; //assuming there is always one item. if (String.IsNullOrEmpty(commandMeta.Content) && (!commandMeta.Xml.HasElements)) { commandMeta = commandItem.Meta; } MetaParser metaParser = new MetaParser(commandMeta.Xml); MetaFormat metaFormat = metaParser.GetMetaFormat(); if (metaFormat != null) { isBase64 = metaFormat.Content == "b64"; } MetaType metaType = metaParser.GetMetaType(); if (metaType == null) { return(null); //the meta element may be empty, so no need to proceed. } // if (contentType == ContactExchangeType.Unknown) //todo: add some exception throw new LocalDataSourceException("expected data is Base64 encoded SIF-C or vCard"); isAddCommand = command is SyncMLAdd; //Assuming there will be only one item. string serverId; string localId = null; serverId = commandItem.Source.LocURI.Content; //id of remote one if (!isAddCommand) { localId = commandItem.Target.LocURI.Content; // entryId of existing contact } string text = GetTextFromContent(isBase64, metaType.Content, commandItem.Data.Content); if (text != null) { localId = isAddCommand ? sifAgent.AddItem(text) : sifAgent.ReplaceItem(text, localId); return(isAddCommand ? localId + "=" + serverId : null); } else { return(null); } }
public MetaEventArgs(MetaType mType, List <int> oids) { this.mType = mType; this.oids = oids; }
internal void Initialize(MetaType metaType, Siaqodb siaqodb, List <Sqo.MetaType> typesList) { Initialize(metaType, siaqodb, typesList, null); }
private void dataGridView1_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (dataGridView1.Rows[e.RowIndex].IsNewRow)//new record { } else { if (e.RowIndex > oids.Count - 1) { } else { if (e.ColumnIndex == 0) { e.Value = oids[e.RowIndex]; } else { MetaField fi = metaType.Fields[e.ColumnIndex - 1]; if (fi.FieldType == null)//complex type { int TID = 0; bool isArray = false; _bs._ltid(this.siaqodb, (int)this.dataGridView1.Rows[e.RowIndex].Cells[0].Value, this.metaType, fi.Name, ref TID, ref isArray); if (TID <= 0) { if (TID == -31) { e.Value = "[Dictionary<,>]"; } else if (TID == -32) { e.Value = "[Jagged Array]"; } else { e.Value = "[null]"; } } else { MetaType mtOfComplex = FindMeta(TID); if (isArray) { string[] name = mtOfComplex.Name.Split(','); e.Value = name[0] + " []"; } else { string[] name = mtOfComplex.Name.Split(','); e.Value = name[0]; } } } else { e.Value = siaqodb.LoadValue(oids[e.RowIndex], metaType.Fields[e.ColumnIndex - 1].Name, metaType); } if (e.Value == null) { e.Value = "[null]"; } } } } }
/// <summary> /// Initializes a new instance of the MetaMessage class. /// </summary> /// <param name="type"> /// The type of MetaMessage. /// </param> /// <param name="data"> /// The MetaMessage data. /// </param> /// <exception cref="ArgumentException"> /// The length of the MetaMessage is not valid for the MetaMessage type. /// </exception> /// <remarks> /// Each MetaMessage has type and length properties. For certain /// types, the length of the message data must be a specific value. For /// example, tempo messages must have a data length of exactly three. /// Some MetaMessage types can have any data length. Text messages are /// an example of a MetaMessage that can have a variable data length. /// When a MetaMessage is created, the length of the data is checked /// to make sure that it is valid for the specified type. If it is not, /// an exception is thrown. /// </remarks> public MetaMessage(MetaType type, byte[] data) { #region Require if(data == null) { throw new ArgumentNullException("data"); } else if(!ValidateDataLength(type, data.Length)) { throw new ArgumentException( "Length of data not valid for meta message type."); } #endregion this.type = type; // Create storage for meta message data. this.data = new byte[data.Length]; // Copy data into storage. data.CopyTo(this.data, 0); CalculateHashCode(); }
public void SetValue(MetaType metaType, string value) { switch (metaType) { case MetaType.Event: this.Event = value; break; case MetaType.Site: this.Site = value; break; case MetaType.Date: this.Date = value; break; case MetaType.Round: this.Round = value; break; case MetaType.White: this.White = value; break; case MetaType.Black: this.Black = value; break; case MetaType.Result: this.Result = value; break; case MetaType.WhiteElo: this.WhiteELO = value; break; case MetaType.BlackElo: this.BlackELO = value; break; case MetaType.ECO: this.ECO = value; break; case MetaType.Annotator: this.Annotator = value; break; case MetaType.Source: this.Source = value; break; case MetaType.Remark: this.Remark = value; break; case MetaType.Filename: this.Filename = value; break; case MetaType.ID: this.ID = value; break; } }
internal SqlNew New(MetaType type, ConstructorInfo cons, IEnumerable <SqlExpression> args, IEnumerable <MemberInfo> argMembers, IEnumerable <SqlMemberAssign> bindings, Expression sourceExpression) => new SqlNew(type, TypeProvider.From(type.Type), cons, args, argMembers, bindings, sourceExpression);
private static void LoadProtoTypeMember(Type myEntity, List <PropertyInfo> Properties, MetaType metaType, List <FieldInfo> Fields, out int maxMemberTag) { int memberTag = 0; Properties.ForEach((o) => { try { var fieldNumber = (o.GetCustomAttributes(typeof(ProtoMemberAttribute), false)[0] as ProtoMemberAttribute).Tag; if (memberTag < fieldNumber) { memberTag = fieldNumber; } if (metaType[fieldNumber] == null) { metaType.Add(fieldNumber, o.Name); } } //忽略异常 catch (Exception ex) { TraceLog.WriteError("Loading protobuf type \"{0}.{1}\" property error:{2}", myEntity.FullName, o.Name, ex); } }); Fields.ForEach((o) => { try { var fieldNumber = (o.GetCustomAttributes(typeof(ProtoMemberAttribute), false)[0] as ProtoMemberAttribute).Tag; if (memberTag < fieldNumber) { memberTag = fieldNumber; } if (metaType[fieldNumber] == null) { metaType.AddField(fieldNumber, o.Name); } } //忽略异常 catch (Exception ex) { TraceLog.WriteError("Loading protobuf type \"{0}.{1}\" field error:{2}", myEntity.FullName, o.Name, ex); } }); maxMemberTag = memberTag; }
internal SqlTable Table(MetaTable table, MetaType rowType, Expression sourceExpression) => new SqlTable(table, rowType, TypeProvider.GetApplicationType(0), sourceExpression);
private IObjectReaderFactory GetDefaultFactory(MetaType rowType) { if(rowType == null) { throw Error.ArgumentNull("rowType"); } SqlNodeAnnotations annotations = new SqlNodeAnnotations(); Expression tmp = Expression.Constant(null); SqlUserQuery suq = new SqlUserQuery(string.Empty, null, null, tmp); if(TypeSystem.IsSimpleType(rowType.Type)) { // if the element type is a simple type (int, bool, etc.) we create // a single column binding SqlUserColumn col = new SqlUserColumn(rowType.Type, _typeProvider.From(rowType.Type), suq, "", false, suq.SourceExpression); suq.Columns.Add(col); suq.Projection = col; } else { // ... otherwise we generate a default projection SqlUserRow rowExp = new SqlUserRow(rowType.InheritanceRoot, _typeProvider.GetApplicationType((int)ConverterSpecialTypes.Row), suq, tmp); suq.Projection = _translator.BuildProjection(rowExp, rowType, true, null, tmp); } Type resultType = TypeSystem.GetSequenceType(rowType.Type); QueryInfo[] qis = this.BuildQuery(ResultShape.Sequence, resultType, suq, null, annotations); return this.GetReaderFactory(qis[qis.Length - 1].Query, rowType.Type); }
internal SqlTableValuedFunctionCall TableValuedFunctionCall(MetaType rowType, Type clrType, string name, IEnumerable <SqlExpression> args, Expression source) => new SqlTableValuedFunctionCall(rowType, clrType, Default(clrType), name, args, source);
private Type GetFieldTypeFrameworkSpecific(int ordinal) => MetaType.GetMetaTypeFromSqlDbType(GetSqlMetaData(ordinal).SqlDbType, false).ClassType;
protected static MetaType Load(IDataRecord reader) { if (reader == null) throw new ArgumentNullException("reader"); MetaType retVal = new MetaType(); retVal._id = (int)reader["DataTypeId"]; retVal._name = (string)reader["Name"]; retVal._friendlyName = (string)reader["FriendlyName"]; if (reader["Description"] != DBNull.Value) retVal._description = (string)reader["Description"]; retVal._length = (int)reader["Length"]; retVal._sqlName = (string)reader["SqlName"]; retVal._allowNulls = (bool)reader["AllowNulls"]; retVal._variable = (bool)reader["Variable"]; retVal._isSqlCommonType = (bool)reader["IsSQLCommonType"]; return retVal; }
/// <summary> /// Determines whether a query result of the given type requires flattening. /// </summary> /// <remarks> /// This method exists to support a performance optimization to skip graph flattening /// of a query result when we discover the entity has no included associations. It takes /// inheritance into account by checking for included associations on the given type as well /// as all types derived from it. /// /// This method evaluates only once per type and caches the result. /// </remarks> /// <param name="domainServiceDescription">The <see cref="DomainServiceDescription"/> to use to examine the entity hierarchy.</param> /// <param name="entityType">The entity type to analyze</param> /// <returns><c>true</c> if a query result of the given <paramref name="entityType"/> requires flattening.</returns> internal static bool RequiresFlattening(DomainServiceDescription domainServiceDescription, Type entityType) { System.Diagnostics.Debug.Assert(domainServiceDescription != null, "domainServiceDescription cannot be null"); System.Diagnostics.Debug.Assert(entityType != null, "entityType cannot be null"); return(requiresFlatteningByType.GetOrAdd(entityType, type => { return (MetaType.GetMetaType(type).IncludedAssociations.Count > 0) || QueryProcessor.GetEntityDerivedTypes(domainServiceDescription, type).Any(t => MetaType.GetMetaType(t).IncludedAssociations.Count > 0); })); }
internal SqlExpression DiscriminatedType(SqlExpression discriminator, MetaType targetType) => new SqlDiscriminatedType(TypeProvider.From(typeof(Type)), discriminator, targetType, discriminator.SourceExpression);
protected TokenType(MetaType type, string text) { _metaType = type; _text = text; }
/// <summary> /// Traverse the result object graph, flattening into a single list. Note that this /// flattening must maintain relative ordering for the top level elements, since the client might /// have passed an order expression. /// </summary> /// <typeparam name="TEntity">The root entity Type of the query.</typeparam> /// <param name="list">The list of entities to add to the results.</param> /// <param name="rootResults">The root entities. The value can be <value>null</value> if the list of root results is already known.</param> /// <param name="includedResults">The included entities.</param> /// <param name="visited">Map used for the lifetime of the flattening to ensure that each entity /// is added to the results only once.</param> /// <param name="domainServiceDescription">description for the DomainService.</param> private static void FlattenGraph <TEntity>(IEnumerable list, List <TEntity> rootResults, List <object> includedResults, HashSet <object> visited, DomainServiceDescription domainServiceDescription) { if (list == null) { return; } // Queue used for breadth-first scan Queue <IEnumerable> resultsQueue = new Queue <IEnumerable>(); resultsQueue.Enqueue(list); IList result = rootResults; while (resultsQueue.Count > 0) { foreach (object entity in resultsQueue.Dequeue()) { if (visited.Contains(entity)) { continue; } // If we already know the root results, then we don't need to copy them over to a new list. if (result != null) { result.Add(entity); } visited.Add(entity); // make sure to use the correct entity Type, taking inheritance into account Type entityType = domainServiceDescription.GetSerializationType(entity.GetType()); PropertyDescriptorCollection properties = MetaType.GetMetaType(entityType).IncludedAssociations; foreach (PropertyDescriptor pd in properties) { IEnumerable value = null; if (typeof(IEnumerable).IsAssignableFrom(pd.PropertyType)) { value = (IEnumerable)pd.GetValue(entity); } else { // singleton association object singleton = pd.GetValue(entity); if (singleton != null) { value = new object[] { singleton }; } } if (value != null) { resultsQueue.Enqueue(value); } } } // From now on, add everything to includedResults. result = includedResults; } }
/// <summary> /// Gets the default object reader factory. /// </summary> /// <param name="rowType">Type of the row.</param> /// <returns></returns> IObjectReaderFactory IProvider.GetDefaultFactory(MetaType rowType) { return this.GetDefaultFactory(rowType); }
internal CallbackSet(MetaType metaType) { this.metaType = metaType ?? throw new ArgumentNullException(nameof(metaType)); }
protected static IdentifierNameSyntax GetRootedTypeSyntax(MetaType metaType) { Requires.Argument(!metaType.IsDefault, nameof(metaType), "Undefined type."); return SyntaxFactory.IdentifierName("Rooted" + metaType.TypeSymbol.Name); }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType1, MetaType metaType2, MetaDictionary <MetaValue, MetaValue> metaValues) { this.owner = owner; this.repository = repository; this.type1 = metaType1; this.type2 = metaType2; this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type2); this.vlVariables.SetValue(this.dictionaryValues.Count > 0 ? this.dictionaryValues[0] : null); }
public void SetData(IRefreshable owner, Repository repository, MetaType metaType1, MetaType metaType2, MetaDictionary<MetaValue, MetaValue> metaValues) { this.owner = owner; this.repository = repository; this.type1 = metaType1; this.type2 = metaType2; this.dictionaryKeys = metaValues.GetKeys(); this.dictionaryValues = metaValues.GetValues(this.dictionaryKeys); this.vlVariables.ClearData(); this.vlVariables.SetData(this, this.repository, this.type2); this.vlVariables.SetValue(this.dictionaryValues.Count > 0 ? this.dictionaryValues[0] : null); }
public void CollectElementsToProxy(IProxyGenerationHook hook, MetaType model) { }
private Type(MetaType type) { this.type = type; this.vectorParameterTypes = null; }
private int GetSortDataType(MetaType mdType) { switch (mdType.Id) { case 31://ShortString return 0; case 32://LongString return 1; case 26://Integer return 2; case 9://Money return 3; case 28://Date return 4; case 4://DateTime return 5; case 34://DictionarySingleValue return 6; case 35://DictionaryMultivalue return 7; case 36://EnumSingleValue return 8; case 37://EnumMultivalue return 9; case 38://StringDictionary return 10; case 27://Boolean return 11; case 30://URL return 12; case 33://LongHtmlString return 13; case 29://Email return 14; case 39://File return 15; case 40://ImageFile return 16; default: return 100; } }
// // Methods /// <summary> /// Initializes the MetaMessageTextBuilder with the specified MetaMessage. /// </summary> /// <param name="message"> /// The MetaMessage to use for initializing the MetaMessageTextBuilder. /// </param> /// <exception cref="ArgumentException"> /// If the MetaMessage is not a text based type. /// </exception> public void Initialize(MetaMessage message) { text = message.Text; this.type = message.MetaType; }
/// <summary> /// Constructor that takes the metadata context, a metadata type and a parent custom type descriptor /// </summary> /// <param name="typeDescriptionContext">The <see cref="LinqToSqlTypeDescriptionContext"/> context.</param> /// <param name="metaType">The <see cref="System.Data.Linq.Mapping.MetaType"/> type.</param> /// <param name="parent">The parent custom type descriptor.</param> public LinqToSqlTypeDescriptor(LinqToSqlTypeDescriptionContext typeDescriptionContext, MetaType metaType, ICustomTypeDescriptor parent) : base(parent) { this._typeDescriptionContext = typeDescriptionContext; this._metaType = metaType; // if any FK member of any association is also part of the primary key, then the key cannot be marked // Editable(false) this._keyIsEditable = this._metaType.Associations.Any(p => p.IsForeignKey && p.ThisKey.Any(q => q.IsPrimaryKey)); }
private static Expr InsertCast(Expr value, Type target) { Type type = new MetaType { instanceType = target }; return new CastExpr { location = value.location, value = value, target = new TypeExpr { type = type, computedType = type }, computedType = target }; }
public static MetaMessage Create(MetaType type, string str) { var tb = new MetaTextBuilder(type, str); return(tb.Result); }
/// <summary> /// Initializes a new instance of the MetaMessageText class with the /// specified meta message. /// </summary> /// <param name="message"> /// The meta message to use for initialization. /// </param> /// <exception cref="ArgumentException"> /// If the meta message is not a text based type. /// </exception> /// <remarks> /// The meta message must be one of the following text based types: /// <list> /// <item> /// Copyright /// </item> /// <item> /// Cuepoint /// </item> /// <item> /// DeviceName /// </item> /// <item> /// InstrumentName /// </item> /// <item> /// Lyric /// </item> /// <item> /// Marker /// </item> /// <item> /// ProgramName /// </item> /// <item> /// Text /// </item> /// <item> /// TrackName /// </item> /// </list> /// If the meta message is not a text based type, an exception will be /// thrown. /// </remarks> public MetaMessageText(MetaMessage message) { // Enforce preconditions. if(!IsTextType(message.Type)) throw new ArgumentException("Not text based meta message.", "message"); this.message = (MetaMessage)message.Clone(); this.type = message.Type; }
public MetaTextBuilder(MetaType type) { this.text = string.Empty; this.type = type; }
/// <summary> /// Initializes a new instance of the MetaMessageText class with the /// specified type. /// </summary> /// <param name="type"> /// The type of meta message. /// </param> /// <exception cref="ArgumentException"> /// If the meta message is not a text based type. /// </exception> /// <remarks> /// The meta message type must be one of the following text based /// types: /// <list> /// <item> /// Copyright /// </item> /// <item> /// Cuepoint /// </item> /// <item> /// DeviceName /// </item> /// <item> /// InstrumentName /// </item> /// <item> /// Lyric /// </item> /// <item> /// Marker /// </item> /// <item> /// ProgramName /// </item> /// <item> /// Text /// </item> /// <item> /// TrackName /// </item> /// </list> /// If the meta message is not a text based type, an exception /// will be thrown. /// </remarks> public MetaMessageText(MetaType type) { // Enforce preconditions. if(!IsTextType(message.Type)) throw new ArgumentException("Not text based meta message type.", "message"); this.type = type; Text = string.Empty; }
internal IEnumerable <RelatedItem> GetParents(MetaType type, object item) => GetRelations(type, item, true);
/// <summary> /// Validates data length. /// </summary> /// <param name="type"> /// The MetaMessage type. /// </param> /// <param name="length"> /// The length of the MetaMessage data. /// </param> /// <returns> /// <b>true</b> if the data length is valid for this type of /// MetaMessage; otherwise, <b>false</b>. /// </returns> private bool ValidateDataLength(MetaType type, int length) { #region Require Debug.Assert(length >= 0); #endregion bool result = true; // Determine which type of meta message this is and check to make // sure that the data length value is valid. switch(type) { case MetaType.SequenceNumber: if(length != 0 && length != 2) { result = false; } break; case MetaType.EndOfTrack: if(length != 0) { result = false; } break; case MetaType.Tempo: if(length != TempoLength) { result = false; } break; case MetaType.SmpteOffset: if(length != SmpteOffsetLength) { result = false; } break; case MetaType.TimeSignature: if(length != TimeSigLength) { result = false; } break; case MetaType.KeySignature: if(length != KeySigLength) { result = false; } break; default: result = true; break; } return result; }
internal IEnumerable <RelatedItem> GetChildren(MetaType type, object item) => GetRelations(type, item, false);
/// <summary> /// Implements the constructor: MetaType() /// </summary> public virtual void MetaType(MetaType @this) { }
/// <summary> /// 系统类型转换为数据库类型 /// </summary> /// <param name="t"></param> /// <returns></returns> public DbType PasteType(Type t) { return(MetaType.GetMetaTypeFromType(t).DbType); }