public IMethodBuilder DeclareAccessor(AccessorType Type, IMethodSignatureTemplate Template) { var result = new LLVMAccessor(this, Type, Template); declaredAccessors.Add(result); return(result); }
public AccessorInfo(AccessorDeclarationSyntax decl, IModifiable parent) { _modifiers = decl.Modifiers.ParseModifiers() .WithDefaultVisibility(parent.Modifiers.First()); Type = decl.Keyword.ToString().StartsWith("get") ? AccessorType.Getter : AccessorType.Setter; }
public void WriteStartAccessor(AccessorType accessor, params string[] modifiers) { //Indent WriteIndent(); //Write Modifiers foreach (string mod in modifiers) { Writer.Write(mod + ' '); } //Write Accessor switch (accessor) { case AccessorType.Get: Writer.Write("get"); break; case AccessorType.Set: Writer.Write("set"); break; case AccessorType.Add: Writer.Write("add"); break; case AccessorType.Remove: Writer.Write("remove"); break; } WriteSpace(); WriteEndExpression(); WriteIndent(); Writer.Write("{"); WriteEndExpression(); indentCount++; }
public static int ComponentCount(this AccessorType accessorType) { switch (accessorType) { case AccessorType.SCALAR: return(1); case AccessorType.VEC2: return(2); case AccessorType.VEC3: return(3); case AccessorType.VEC4: return(4); case AccessorType.MAT2: return(4); case AccessorType.MAT3: return(9); case AccessorType.MAT4: return(16); default: Debug.LogError("AccessorType " + accessorType + " not supported!"); return(0); } }
public void ValidateRecordAccessors(IResolver resolver, string name, AccessorType accessor) { var query = GetRecord(resolver, name); Assert.True(query?.Accessor == accessor, $"{resolver.GetType().FullName}: The '{name}' accessor type is invalid. Expected '{accessor}' != Actual '{query?.Accessor}'"); }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="accessorType"></param> /// <returns></returns> public static IClassAccessor GetClassAccessor(object target, AccessorType accessorType) { ArgumentAssertion.IsNotNull(target, "target"); var type = target.GetType(); return(GetClassAccessor(type, accessorType)); }
/// <summary> /// /// </summary> /// <param name="targetType"></param> /// <param name="accessorType"></param> /// <returns></returns> public static IClassAccessor GetClassAccessor(Type targetType, AccessorType accessorType) { ArgumentAssertion.IsNotNull(targetType, "targetType"); IClassAccessor accessor = null; var typeKey = string.Format("{0}.{1}", accessorType, targetType.FullName); if (ClassAccessores.ContainsKey(typeKey)) { accessor = ClassAccessores[typeKey]; } else { lock (SyncObject) { if (ClassAccessores.ContainsKey(typeKey)) { accessor = ClassAccessores[typeKey]; } else { accessor = ClassAccessorFactory.CreateClassAccessor(targetType, accessorType); ClassAccessores.Add(typeKey, accessor); } } } return(accessor); }
public static bool ValidateAccessorTypeAny(AccessorType type, params AccessorType[] expected) { for (int i = 0; i < expected.Length; i++) { if (type == expected[i]) return true; } Debug.Log("Type mismatch! Expected " + string.Join("or ", expected) + ", got " + type); return false; }
private static bool ValidateAccessorType(AccessorType type, AccessorType expected) { if (type == expected) return true; else { Debug.LogError("Type mismatch! Expected " + expected + " got " + type); return false; } }
private static Accessor CreateAccessor(AccessorType accessorType) { var space = typeof(Accessor).Namespace; return((Accessor)Activator.CreateInstance( Type.GetType(typeName: $"{space}.{accessorType.ToString()}Accessor"))); }
/// <summary> /// Initializes a new instance of the Accessor class. /// </summary> /// <param name="document"> /// The document that contains the element. /// </param> /// <param name="parent"> /// The parent of the element. /// </param> /// <param name="accessorType"> /// The type of the accessor. /// </param> /// <param name="header"> /// The Xml header for this element. /// </param> /// <param name="attributes"> /// The list of attributes attached to this element. /// </param> /// <param name="declaration"> /// The declaration code for this element. /// </param> /// <param name="unsafeCode"> /// Indicates whether the element resides within a block of unsafe code. /// </param> /// <param name="generated"> /// Indicates whether the code element was generated or written by hand. /// </param> internal Accessor( CsDocument document, CsElement parent, AccessorType accessorType, XmlHeader header, ICollection<Attribute> attributes, Declaration declaration, bool unsafeCode, bool generated) : base(document, parent, ElementType.Accessor, declaration.Name + " accessor", header, attributes, declaration, unsafeCode, generated) { Param.AssertNotNull(document, "document"); Param.AssertNotNull(parent, "parent"); Param.Ignore(accessorType); Param.Ignore(header); Param.Ignore(attributes); Param.AssertNotNull(declaration, "declaration"); Param.Ignore(unsafeCode); Param.Ignore(generated); this.accessorType = accessorType; // Make sure the type and name match. Debug.Assert( (accessorType == AccessorType.Get && declaration.Name == "get") || (accessorType == AccessorType.Set && declaration.Name == "set") || (accessorType == AccessorType.Add && declaration.Name == "add") || (accessorType == AccessorType.Remove && declaration.Name == "remove"), "The accessor type does not match its name."); this.FillDetails(parent); }
/// <summary> /// Initializes a new instance of the Accessor class. /// </summary> /// <param name="document"> /// The document that contains the element. /// </param> /// <param name="parent"> /// The parent of the element. /// </param> /// <param name="accessorType"> /// The type of the accessor. /// </param> /// <param name="header"> /// The Xml header for this element. /// </param> /// <param name="attributes"> /// The list of attributes attached to this element. /// </param> /// <param name="declaration"> /// The declaration code for this element. /// </param> /// <param name="unsafeCode"> /// Indicates whether the element resides within a block of unsafe code. /// </param> /// <param name="generated"> /// Indicates whether the code element was generated or written by hand. /// </param> internal Accessor( CsDocument document, CsElement parent, AccessorType accessorType, XmlHeader header, ICollection <Attribute> attributes, Declaration declaration, bool unsafeCode, bool generated) : base(document, parent, ElementType.Accessor, declaration.Name + " accessor", header, attributes, declaration, unsafeCode, generated) { Param.AssertNotNull(document, "document"); Param.AssertNotNull(parent, "parent"); Param.Ignore(accessorType); Param.Ignore(header); Param.Ignore(attributes); Param.AssertNotNull(declaration, "declaration"); Param.Ignore(unsafeCode); Param.Ignore(generated); this.accessorType = accessorType; // Make sure the type and name match. Debug.Assert( (accessorType == AccessorType.Get && declaration.Name == "get") || (accessorType == AccessorType.Set && declaration.Name == "set") || (accessorType == AccessorType.Add && declaration.Name == "add") || (accessorType == AccessorType.Remove && declaration.Name == "remove"), "The accessor type does not match its name."); this.FillDetails(parent); }
public LLVMAccessor( LLVMProperty DeclaringProperty, AccessorType AccessorType, IMethodSignatureTemplate Template) : base(DeclaringProperty.ParentType, Template) { this.AccessorType = AccessorType; this.DeclaringProperty = DeclaringProperty; }
public RDomPropertyAccessor(IDom parent, string name, AccessorType accessorType, AccessModifier declaredAccessModifier = AccessModifier.Private) : base(parent) { Initialize(); _name = name; DeclaredAccessModifier = declaredAccessModifier; // Must use the setter here! _accessorType = accessorType; NeedsFormatting = true; }
private static bool ValidateAccessorType(AccessorType type, AccessorType expected) { if (type != expected) { Debug.LogError("Type mismatch! Expected " + expected + " got " + type); return(false); } return(true); }
public IDataAccessor GetDataAccessor(AccessorType type) { if (type == AccessorType.SqlServer) { return(new SqlDataAccessor()); } else { throw new NotImplementedException("还没有实现!"); } }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="propertyValues"></param> /// <param name="accessorType"></param> public static void SetPropertyValues(this object target, IDictionary <string, object> propertyValues, AccessorType accessorType) { ArgumentAssertion.IsNotNull(propertyValues, "propertyValues"); var accessor = ClassAccessorRepository.GetClassAccessor(target, accessorType); foreach (var pair in propertyValues) { accessor.SetValue(target, pair.Key, pair.Value); } }
internal RDomPropertyAccessor(RDomPropertyAccessor oldRDom) : base(oldRDom) { Initialize(); Attributes.AddOrMoveAttributeRange(oldRDom.Attributes.Select(x => x.Copy())); _statements = oldRDom.StatementsAll.Copy(this); _name = oldRDom.Name; _accessModifier = oldRDom.AccessModifier; _declaredAccessModifier = oldRDom.DeclaredAccessModifier; _hasBlock = oldRDom.HasBlock; _accessorType = oldRDom.AccessorType; }
public IDataAccessor GetDataAccessor(AccessorType type, bool IsPwdEncript) { if (type == AccessorType.SqlServer) { SqlDataAccessor sda = new SqlDataAccessor(); sda.IsPwdEncript = IsPwdEncript; return(sda); } else { throw new NotImplementedException("还没有实现!"); } }
public string Generate(AccessorType type) { switch (type) { case AccessorType.Pointer: return("->"); case AccessorType.Static: return("::"); } throw new NotImplementedException(); }
glTFAccessor CreateGltfAccessor(int viewIndex, int count = 0, int byteOffset = 0) { if (count == 0) { count = Count; } return(new glTFAccessor { bufferView = viewIndex, byteOffset = byteOffset, componentType = (glComponentType)ComponentType, type = AccessorType.ToString(), count = count, }); }
/// <summary> /// Initializes a new instance of the Accessor class. /// </summary> /// <param name="proxy">Proxy object for the accessor.</param> /// <param name="name">The name of the accessor.</param> /// <param name="accessorType">The type of the accessor.</param> /// <param name="unsafeCode">Indicates whether the element resides within a block of unsafe code.</param> internal Accessor(CodeUnitProxy proxy, string name, AccessorType accessorType, bool unsafeCode) : base(proxy, (int)accessorType, name, null, unsafeCode) { Param.AssertNotNull(proxy, "proxy"); Param.AssertValidString(name, "name"); Param.Ignore(accessorType); Param.Ignore(unsafeCode); // Make sure the type and name match. CsLanguageService.Debug.Assert( (accessorType == AccessorType.Get && name == "get") || (accessorType == AccessorType.Set && name == "set") || (accessorType == AccessorType.Add && name == "add") || (accessorType == AccessorType.Remove && name == "remove"), "The accessor type does not match its name."); }
private static T GetValue <T>(SqlDataReader reader, int ordinal, AccessorType accesor) { switch (accesor) { case AccessorType.GetFieldValue: return(GetFieldValue <T>(reader, ordinal)); case AccessorType.GetFieldValueAsync: return(GetFieldValueAsync <T>(reader, ordinal)); case AccessorType.GetNamedValue: return(GetNamedValue <T>(reader, ordinal)); default: throw new NotSupportedException(); } }
public IDataAccessor GetDataAccessor(AccessorType type, string connStr) { if (type == AccessorType.SqlServer) { if (string.IsNullOrEmpty(connStr)) { return(new SqlDataAccessor()); } else { return(new SqlDataAccessor(connStr)); } } else { throw new NotImplementedException("还没有实现!"); } }
public void WriteAccessor(AccessorType accessor) { //Indent WriteIndent(); //Write Accessor switch (accessor) { case AccessorType.Get: Writer.Write("get"); break; case AccessorType.Set: Writer.Write("set"); break; case AccessorType.Add: Writer.Write("add"); break; case AccessorType.Remove: Writer.Write("remove"); break; } //End Writer.Write(";"); WriteEndExpression(); }
public static string ToText(string xmlContent, string @namespace = null, AccessorType accessorType = AccessorType.Public) { var hasNamespace = !string.IsNullOrEmpty(@namespace); var src = GenerateCsharpSource(xmlContent, @namespace, accessorType).Aggregate((x, y) => x + Environment.NewLine + y); var sb = new StringBuilder(); sb.AppendLine("using System.Collections.Generic;"); sb.AppendLine("using System.Xml.Serialization;"); sb.AppendLine(); if (hasNamespace) { sb.AppendLine($"namespace {@namespace}"); sb.AppendLine("{"); } sb.AppendLine(src); if (hasNamespace) { sb.AppendLine("}"); } return(sb.ToString()); }
/// <summary> /// /// </summary> /// <param name="targetType"></param> /// <param name="accessorType"></param> /// <returns></returns> public static IClassAccessor CreateClassAccessor(Type targetType, AccessorType accessorType) { IClassAccessor accessor = null; switch (accessorType) { case AccessorType.Reflection: { accessor = new ReflectionClassAccessor(targetType); break; } default: { accessor = new EmitClassAccessor(targetType); break; } } return(accessor); }
public IDataAccessor GetDataAccessor(AccessorType type, string connStr, bool IsPwdEncript) { if (type == AccessorType.SqlServer) { if (string.IsNullOrEmpty(connStr)) { SqlDataAccessor sda = new SqlDataAccessor(); sda.IsPwdEncript = IsPwdEncript; return(sda); } else { SqlDataAccessor sda = new SqlDataAccessor(connStr); sda.IsPwdEncript = IsPwdEncript; return(sda); } } else { throw new NotImplementedException("还没有实现!"); } }
public void WriteStartAccessor(AccessorType accessor) { //Indent WriteIndent(); //Write Accessor switch (accessor) { case AccessorType.Get: Writer.Write("get"); break; case AccessorType.Set: Writer.Write("set"); break; case AccessorType.Add: Writer.Write("add"); break; case AccessorType.Remove: Writer.Write("remove"); break; } WriteSpace(); WriteEndExpression(); WriteIndent(); Writer.Write("{"); WriteEndExpression(); indentCount++; }
public static void InvalidCastExceptionStream(CommandBehavior behavior, AccessorType accessorType) { string query = "SELECT convert(xml,NULL) AS XmlData, convert(nvarchar(max),NULL) as TextData"; using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) using (SqlCommand command = new SqlCommand(query, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader(behavior)) { Assert.True(reader.Read(), "It's excpected to read a row."); InvalidCastException ex = Assert.Throws <InvalidCastException>(() => GetValue <TextReader>(reader, 0, accessorType)); Assert.Contains("The GetTextReader function can only be used on columns of type Char, NChar, NText, NVarChar, Text or VarChar.", ex.Message); ex = Assert.Throws <InvalidCastException>(() => GetValue <Stream>(reader, 0, accessorType)); Assert.Contains("The GetStream function can only be used on columns of type Binary, Image, Udt or VarBinary.", ex.Message); ex = Assert.Throws <InvalidCastException>(() => GetValue <XmlReader>(reader, 1, accessorType)); Assert.Contains("The GetXmlReader function can only be used on columns of type Xml.", ex.Message); } } }
private static string GetAccessor(AccessorType accessorType) { var accessor = ""; switch (accessorType) { case AccessorType.Public: accessor = "public"; break; case AccessorType.Private: accessor = "private"; break; case AccessorType.Internal: accessor = "internal"; break; case AccessorType.Protected: accessor = "protected"; break; } return(accessor); }
static string GetAccessorName (AccessorType at) { if (at == AccessorType.Set) return "set"; if (at == AccessorType.Get) return "get"; throw new NotImplementedException (at.ToString ()); }
Expression ResolveAccessor (EmitContext ec, AccessorType accessorType) { if (!CommonResolve (ec)) return null; Indexers ilist = Indexers.GetIndexersForType (current_type, indexer_type); if (ilist.Methods == null) { Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", TypeManager.CSharpName (indexer_type)); return null; } MethodGroupExpr mg = new IndexerMethodGroupExpr (ilist, loc); mg = mg.OverloadResolve (ec, ref arguments, false, loc); if (mg == null) return null; MethodInfo mi = (MethodInfo) mg; PropertyInfo pi = null; for (int i = 0; i < ilist.Methods.Count; ++i) { if (ilist.Methods [i] == mi) { pi = (PropertyInfo) ilist.Properties [i]; break; } } type = TypeManager.TypeToCoreType (pi.PropertyType); if (type.IsPointer && !ec.InUnsafe) UnsafeError (loc); MethodInfo accessor; if (accessorType == AccessorType.Get) { accessor = get = pi.GetGetMethod (true); } else { accessor = set = pi.GetSetMethod (true); if (accessor == null && pi.GetGetMethod (true) != null) { Report.SymbolRelatedToPreviousError (pi); Report.Error (200, loc, "The read only property or indexer `{0}' cannot be assigned to", TypeManager.GetFullNameSignature (pi)); return null; } } if (accessor == null) { Report.SymbolRelatedToPreviousError (pi); Report.Error (154, loc, "The property or indexer `{0}' cannot be used in this context because it lacks a `{1}' accessor", TypeManager.GetFullNameSignature (pi), GetAccessorName (accessorType)); return null; } // // Only base will allow this invocation to happen. // if (accessor.IsAbstract && this is BaseIndexerAccess) { Error_CannotCallAbstractBase (TypeManager.GetFullNameSignature (pi)); } bool must_do_cs1540_check; if (!IsAccessorAccessible (ec.ContainerType, accessor, out must_do_cs1540_check)) { if (set == null) set = pi.GetSetMethod (true); else get = pi.GetGetMethod (true); if (set != null && get != null && (set.Attributes & MethodAttributes.MemberAccessMask) != (get.Attributes & MethodAttributes.MemberAccessMask)) { Report.SymbolRelatedToPreviousError (accessor); Report.Error (271, loc, "The property or indexer `{0}' cannot be used in this context because a `{1}' accessor is inaccessible", TypeManager.GetFullNameSignature (pi), GetAccessorName (accessorType)); } else { Report.SymbolRelatedToPreviousError (pi); ErrorIsInaccesible (loc, TypeManager.GetFullNameSignature (pi)); } } instance_expr.CheckMarshalByRefAccess (ec); eclass = ExprClass.IndexerAccess; return this; }
public PropertyAccessor SetAccessorType(AccessorType t) { this.AccessorType = t; return this; }