public CustomMethodEmitter(CustomClassEmitter declaringType, string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("attributes", attributes); ArgumentUtility.CheckNotNull("returnType", returnType); ArgumentUtility.CheckNotNull("parameterTypes", parameterTypes); MethodEmitter innerEmitter = declaringType.InnerEmitter.CreateMethod(name, attributes, returnType, parameterTypes); _innerEmitter = innerEmitter; _declaringType = declaringType; _name = name; _parameterTypes = parameterTypes; }
public ITypeBuilder DefineType(string name, TypeAttributes attributes, IEmittableOperandProvider emittableOperandProvider) { ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("emittableOperandProvider", emittableOperandProvider); if (_moduleContext.ModuleBuilder == null) { var assemblyName = GetNextAssemblyName(); _moduleContext.ModuleBuilder = _moduleBuilderFactory.CreateModuleBuilder(assemblyName, _assemblyDirectory, _forceStrongNaming, _keyFilePath); } var typeBuilder = _moduleContext.ModuleBuilder.DefineType(name, attributes); return(new TypeBuilderDecorator(typeBuilder, emittableOperandProvider)); }
/// <summary> /// Waits for the WXE function token to change from <paramref name="oldWxeFunctionToken"/> to a new function token. /// </summary> public static void WaitForNewWxeFunctionToken([NotNull] ILog log, [NotNull] PageObjectContext context, [NotNull] string oldWxeFunctionToken) { ArgumentUtility.CheckNotNull("log", log); ArgumentUtility.CheckNotNull("context", context); ArgumentUtility.CheckNotNullOrEmpty("oldWxeFunctionToken", oldWxeFunctionToken); log.DebugFormat("State: previous WXE-FT: {0}.", oldWxeFunctionToken); log.DebugFormat("Parameters: window: '{0}' scope: '{1}'.", context.Window.Title, GetPageTitle(context)); context.Window.Query(() => GetWxeFunctionToken(context) != oldWxeFunctionToken, true); Assertion.IsTrue( GetWxeFunctionToken(context) != oldWxeFunctionToken, string.Format("Expected WXE-FT to be different to '{0}', but it is equal.", oldWxeFunctionToken)); }
/// <summary> Gets the <see cref="Type"/> for the specified <paramref name="absolutePath"/>. </summary> /// <include file='..\doc\include\ExecutionEngine\WxeHandler.xml' path='WxeHandler/GetTypeByPath/*' /> protected virtual Type GetTypeByPath(string absolutePath) { ArgumentUtility.CheckNotNullOrEmpty("absolutePath", absolutePath); string relativePath = VirtualPathUtility.ToAppRelative(absolutePath); Type type = UrlMapping.UrlMappingConfiguration.Current.Mappings.FindType(relativePath); if (type == null) { throw new WxeException(string.Format("Could not map the path '{0}' to a WXE function.", absolutePath)); } return(type); }
public static AppDomainAssemblyResolver CreateInAppDomain(AppDomain appDomain, string applicationBase) { ArgumentUtility.CheckNotNull("appDomain", appDomain); ArgumentUtility.CheckNotNullOrEmpty("applicationBase", applicationBase); return((AppDomainAssemblyResolver)appDomain.CreateInstanceFromAndUnwrap( typeof(AppDomainAssemblyResolver).Assembly.Location, typeof(AppDomainAssemblyResolver).FullName, false, BindingFlags.Public | BindingFlags.Instance, null, new[] { applicationBase }, null, null)); }
public void VerifyPEFile(string modulePath, PEVerifyVersion version) { ArgumentUtility.CheckNotNullOrEmpty("modulePath", modulePath); var process = StartPEVerifyProcess(modulePath, version); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); if (process.ExitCode != 0) { throw new PEVerifyException(process.ExitCode, output); } }
public static Type GetItemTypeOfClosedGenericIEnumerable(Type enumerableType, string argumentName) { ArgumentUtility.CheckNotNull("enumerableType", enumerableType); ArgumentUtility.CheckNotNullOrEmpty("argumentName", argumentName); Type itemType; if (!ItemTypeReflectionUtility.TryGetItemTypeOfClosedGenericIEnumerable(enumerableType, out itemType)) { var message = string.Format("Expected a closed generic type implementing IEnumerable<T>, but found '{0}'.", enumerableType); throw new ArgumentException(message, argumentName); } return(itemType); }
public static Type GetItemTypeOfIEnumerable(Type enumerableType, string argumentName) { ArgumentUtility.CheckNotNull("enumerableType", enumerableType); ArgumentUtility.CheckNotNullOrEmpty("argumentName", argumentName); Type itemType = TryGetItemTypeOfIEnumerable(enumerableType); if (itemType == null) { var message = string.Format("Expected a type implementing IEnumerable<T>, but found '{0}'.", enumerableType.FullName); throw new ArgumentTypeException(message, argumentName, typeof(IEnumerable <>), enumerableType); } return(itemType); }
public StorageProvider GetMandatory(string storageProviderID) { CheckDisposed(); ArgumentUtility.CheckNotNullOrEmpty("storageProviderID", storageProviderID); StorageProvider provider = this[storageProviderID]; if (provider == null) { throw CreatePersistenceException( "Storage Provider with ID '{0}' could not be created.", storageProviderID); } return(provider); }
public IExpressionNode Parse( string associatedIdentifier, IExpressionNode source, IEnumerable <Expression> arguments, MethodCallExpression expressionToParse) { ArgumentUtility.CheckNotNullOrEmpty("associatedIdentifier", associatedIdentifier); ArgumentUtility.CheckNotNull("source", source); ArgumentUtility.CheckNotNull("expressionToParse", expressionToParse); ArgumentUtility.CheckNotNull("arguments", arguments); Type nodeType = GetNodeType(expressionToParse); var additionalConstructorParameters = arguments.Select(ProcessArgumentExpression).ToArray(); var parseInfo = new MethodCallExpressionParseInfo(associatedIdentifier, source, expressionToParse); return(CreateExpressionNode(nodeType, parseInfo, additionalConstructorParameters)); }
public MainSourceExpressionNode(string associatedIdentifier, Expression expression) { ArgumentUtility.CheckNotNullOrEmpty("associatedIdentifier", associatedIdentifier); ArgumentUtility.CheckNotNull("expression", expression); ArgumentUtility.CheckTypeIsAssignableFrom("expression.Type", expression.Type, typeof(IEnumerable)); _querySourceType = expression.Type; if (!ItemTypeReflectionUtility.TryGetItemTypeOfClosedGenericIEnumerable(expression.Type, out _querySourceElementType)) { _querySourceElementType = typeof(object); } _associatedIdentifier = associatedIdentifier; _parsedExpression = expression; }
public IList <IPrimaryKeySchema> GetSchema(DbConnection connection, string tableName) { ArgumentUtility.CheckNotNull("connection", connection); ArgumentUtility.CheckNotNullOrEmpty("tableName", tableName); var primaryKeys = new List <IPrimaryKeySchema>(); var indexes = this.GetDataTable(connection, tableName); var isDbc = this.IsDbc(connection); indexes.AsEnumerable() .Where(row => Convert.ToBoolean(row["PRIMARY_KEY"])) .ForEach(row => primaryKeys.Add(new PrimaryKeySchema(row["COLUMN_NAME"].ToString(), isDbc && this.IsAutoIncrement(connection, row)))); return(primaryKeys); }
public ResolvedJoinInfo ResolveJoin( SqlEntityExpression originatingEntity, IRelationEndPointDefinition leftEndPoint, IRelationEndPointDefinition rightEndPoint, string tableAlias) { ArgumentUtility.CheckNotNull("originatingEntity", originatingEntity); ArgumentUtility.CheckNotNull("leftEndPoint", leftEndPoint); ArgumentUtility.CheckNotNullOrEmpty("tableAlias", tableAlias); var leftKey = GetJoinColumn(leftEndPoint, originatingEntity); var resolvedSimpleTableInfo = ResolveTable(rightEndPoint.ClassDefinition, tableAlias); var rightEntity = ResolveEntity(rightEndPoint.ClassDefinition, tableAlias); Expression rightKey = GetJoinColumn(rightEndPoint, rightEntity); return(new ResolvedJoinInfo(resolvedSimpleTableInfo, Expression.Equal(leftKey, rightKey))); }
public SearchPathRootAssemblyFinder( string baseDirectory, string relativeSearchPath, bool considerDynamicDirectory, string dynamicDirectory, IAssemblyLoader assemblyLoader) { ArgumentUtility.CheckNotNullOrEmpty("baseDirectory", baseDirectory); ArgumentUtility.CheckNotNull("assemblyLoader", assemblyLoader); _baseDirectory = baseDirectory; _relativeSearchPath = relativeSearchPath; _considerDynamicDirectory = considerDynamicDirectory; _dynamicDirectory = dynamicDirectory; _assemblyLoader = assemblyLoader; }
public ResolvedSubStatementTableInfo(string tableAlias, SqlStatement sqlStatement) { ArgumentUtility.CheckNotNullOrEmpty("tableAlias", tableAlias); ArgumentUtility.CheckNotNull("sqlStatement", sqlStatement); _sqlStatement = sqlStatement; _tableAlias = tableAlias; var streamedSequenceInfo = sqlStatement.DataInfo as StreamedSequenceInfo; if (streamedSequenceInfo == null) { throw new ArgumentException("For a statement to be used as a table, it must return a sequence of items.", "sqlStatement"); } _itemType = streamedSequenceInfo.ResultItemType; }
public FilePatternRootAssemblyFinder( string searchPath, IEnumerable <FilePatternSpecification> specifications, IFileSearchService fileSearchService, IAssemblyLoader assemblyLoader) { ArgumentUtility.CheckNotNullOrEmpty("searchPath", searchPath); ArgumentUtility.CheckNotNull("specifications", specifications); ArgumentUtility.CheckNotNull("fileSearchService", fileSearchService); ArgumentUtility.CheckNotNull("assemblyLoader", assemblyLoader); _searchPath = searchPath; _specifications = specifications.ToList().AsReadOnly(); _fileSearchService = fileSearchService; _assemblyLoader = assemblyLoader; }
public IRelationEndPointDefinition GetEndPointDefinition(string classID, string propertyName) { ArgumentUtility.CheckNotNullOrEmpty("classID", classID); if (_endPointDefinition1.ClassDefinition.ID == classID && _endPointDefinition1.PropertyName == propertyName) { return(_endPointDefinition1); } if (_endPointDefinition2.ClassDefinition.ID == classID && _endPointDefinition2.PropertyName == propertyName) { return(_endPointDefinition2); } return(null); }
/// <summary> /// Gets the value of the specified string resource. /// </summary> public bool TryGetString(string id, out string value) { ArgumentUtility.CheckNotNullOrEmpty("id", id); string result = _resourceManager.GetString(id); if (result != null) { value = result; return(true); } s_log.DebugFormat("Could not find resource with ID '{0}' in resource container '{1}'.", id, _resourceManager.BaseName); value = null; return(false); }
public WebServiceExceutionException(long readyState, [NotNull] string responseText, long status, [NotNull] string statusText) : base( string.Format( "The web service call failed with status '{0} - {1}'. The returned JSON object was: '{2}'.", status, statusText, responseText)) { ArgumentUtility.CheckNotNullOrEmpty("responseText", responseText); ArgumentUtility.CheckNotNullOrEmpty("statusText", statusText); _readyState = readyState; _responseText = responseText; _status = status; _statusText = statusText; }
public IEnumerable <PersistableData> GetLoadedDataByObjectState(params StateType[] domainObjectStates) { ArgumentUtility.CheckNotNullOrEmpty("domainObjectStates", domainObjectStates); var stateSet = new StateValueSet(domainObjectStates); var matchingObjects = from dataContainer in DataContainers let domainObject = dataContainer.DomainObject let state = domainObject.TransactionContext[_clientTransaction].State where stateSet.Matches(state) let associatedEndPointSequence = dataContainer.AssociatedRelationEndPointIDs.Select(GetRelationEndPointWithoutLoading).Where(ep => ep != null) select new PersistableData(domainObject, state, dataContainer, associatedEndPointSequence); return(matchingObjects); }
public AssociationSchema(string associationName, string tableName, string columnName, string relatedTableName, string relatedColumnName, AssociationType associationType) { ArgumentUtility.CheckNotNullOrEmpty("associationName", associationName); ArgumentUtility.CheckNotNullOrEmpty("tableName", tableName); ArgumentUtility.CheckNotNullOrEmpty("columnName", columnName); ArgumentUtility.CheckNotNullOrEmpty("relatedTableName", relatedTableName); ArgumentUtility.CheckNotNullOrEmpty("relatedColumnName", relatedColumnName); ArgumentUtility.CheckIsDefined("associationType", associationType); this.AssociationName = associationName; this.TableName = tableName; this.ColumnName = columnName; this.RelatedTableName = relatedTableName; this.RelatedColumnName = relatedColumnName; this.AssociationType = associationType; }
public SqlCommandData( string commandText, CommandParameter[] parameters, ParameterExpression inMemoryProjectionParameter, Expression inMemoryProjectionBody) { ArgumentUtility.CheckNotNullOrEmpty("commandText", commandText); ArgumentUtility.CheckNotNull("parameters", parameters); ArgumentUtility.CheckNotNull("inMemoryProjectionParameter", inMemoryProjectionParameter); ArgumentUtility.CheckNotNull("inMemoryProjectionBody", inMemoryProjectionBody); _commandText = commandText; _parameters = parameters; _inMemoryProjectionParameter = inMemoryProjectionParameter; _inMemoryProjectionBody = inMemoryProjectionBody; }
/// <summary> /// Gets an <see cref="ExtensibleEnumInfo{T}"/> object describing the enum value identified by <paramref name="id"/>, throwing an exception if the /// value cannot be found. /// </summary> /// <param name="id">The identifier of the enum value to return.</param> /// <returns>An <see cref="ExtensibleEnumInfo{T}"/> describing the enum value identified by <paramref name="id"/>.</returns> /// <exception cref="KeyNotFoundException">No enum value with the given <paramref name="id"/> exists.</exception> public ExtensibleEnumInfo <T> GetValueInfoByID(string id) { ArgumentUtility.CheckNotNullOrEmpty("id", id); ExtensibleEnumInfo <T> value; if (TryGetValueInfoByID(id, out value)) { return(value); } else { var message = string.Format("The extensible enum type '{0}' does not define a value called '{1}'.", typeof(T), id); throw new KeyNotFoundException(message); } }
/// <summary> /// Deserializes a configuration section and optionally validates the supplied <paramref name="xmlFragment"/> against a XML schema. /// </summary> /// <param name="configurationSection">The configuration to populate from the fragment.</param> /// <param name="xmlFragment">The XML fragment.</param> /// <param name="xsdContent">The content of the XSD, or <see langword="null"/> for no validation.</param> public static void DeserializeSection(ConfigurationSection configurationSection, string xmlFragment, string xsdContent = null) { ArgumentUtility.CheckNotNull("configurationSection", configurationSection); ArgumentUtility.CheckNotNullOrEmpty("xmlFragment", xmlFragment); using (XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Document, null)) { reader.WhitespaceHandling = WhitespaceHandling.None; PrivateInvoke.InvokeNonPublicMethod(configurationSection, "DeserializeSection", reader); } if (xsdContent != null) { XmlSchemaValidation.Validate(xmlFragment, xsdContent); } }
/// <summary> /// Creates an additional <see cref="MutableType"/> representing an public top-level class. /// </summary> /// <param name="context">A type assembly context.</param> /// <param name="additionalTypeID">The ID of the type.</param> /// <param name="name">The class name.</param> /// <param name="namespace">The namespace of the class.</param> /// <param name="baseType">The base type of the class.</param> /// <returns>A new mutable type representing a class.</returns> public static MutableType CreateClass( [NotNull] this ITypeAssemblyContext context, [NotNull] object additionalTypeID, [NotNull] string name, [CanBeNull] string @namespace, [NotNull] Type baseType) { ArgumentUtility.CheckNotNull("context", context); ArgumentUtility.CheckNotNull("additionalTypeID", additionalTypeID); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("baseType", baseType); var attributes = TypeAttributes.Public | TypeAttributes.Class; return(context.CreateAdditionalType(additionalTypeID, name, @namespace, attributes, baseType)); }
/// <summary> /// Find an element with the given <paramref name="tagSelector"/> bearing a given attribute name/value combination (value is compared using the /// given <paramref name="op"/>). /// </summary> /// <param name="scope">The parent <see cref="ElementScope"/> which serves as the root element for the search.</param> /// <param name="tagSelector">The CSS selector for the HTML tags to check for the attributes.</param> /// <param name="op">The CSS operator to use when comparing the <paramref name="attributeValue"/>.</param> /// <param name="attributeName">The attribute name.</param> /// <param name="attributeValue">The attribute value.</param> /// <returns>The <see cref="ElementScope"/> of the found element.</returns> public static ElementScope FindTagWithAttributeUsingOperator( [NotNull] this ElementScope scope, [NotNull] string tagSelector, CssComparisonOperator op, [NotNull] string attributeName, [NotNull] string attributeValue) { ArgumentUtility.CheckNotNull("scope", scope); ArgumentUtility.CheckNotNullOrEmpty("tagSelector", tagSelector); ArgumentUtility.CheckNotNullOrEmpty("attributeName", attributeName); ArgumentUtility.CheckNotNullOrEmpty("attributeValue", attributeValue); var cssSelector = string.Format("{0}[{1}{2}'{3}']", tagSelector, attributeName, op.ToCssString(), attributeValue); return(scope.FindCss(cssSelector)); }
public static MutableMethodInfo AddAbstractMethod( this MutableType declaringType, string name, MethodAttributes attributes = MethodAttributes.Public, Type returnType = null, IEnumerable <ParameterDeclaration> parameters = null) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); returnType = returnType ?? typeof(void); parameters = parameters ?? ParameterDeclaration.None; var abstractAttributes = attributes.Set(MethodAttributes.Abstract | MethodAttributes.Virtual); return(declaringType.AddMethod(name, abstractAttributes, returnType, parameters, bodyProvider: null)); }
public static MutableMethodInfo AddMethod( this MutableType declaringType, string name, MethodAttributes attributes, MethodDeclaration methodDeclaration, Func <MethodBodyCreationContext, Expression> bodyProvider) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("methodDeclaration", methodDeclaration); // Body provider may be null (for abstract methods). var md = methodDeclaration; return(declaringType.AddMethod(name, attributes, md.GenericParameters, md.ReturnTypeProvider, md.ParameterProvider, bodyProvider)); }
public void ExecutePage(WxeContext context, string page, bool isPostBack) { ArgumentUtility.CheckNotNull("context", context); ArgumentUtility.CheckNotNullOrEmpty("page", page); string url = page; string queryString = context.HttpContext.Request.Url.Query; if (!string.IsNullOrEmpty(queryString)) { queryString = queryString.Replace(":", HttpUtility.UrlEncode(":")); if (url.Contains("?")) { url = url + "&" + queryString.TrimStart('?'); } else { url = url + queryString; } } WxeHandler wxeHandlerBackUp = context.HttpContext.Handler as WxeHandler; Assertion.IsNotNull(wxeHandlerBackUp, "The HttpHandler must be of type WxeHandler."); try { context.HttpContext.Server.Transfer(url, isPostBack); } catch (HttpException httpException) { if (httpException.InnerException is WxeExecutionControlException) { return; } if (httpException.GetHttpCode() == HttpStatusCode_NotFound) { throw new WxeResourceNotFoundException(string.Format("The page '{0}' does not exist.", page), httpException); } throw; } finally { context.HttpContext.Handler = wxeHandlerBackUp; } }
public MutablePropertyInfo CreateProperty( MutableType declaringType, string name, Type type, IEnumerable <ParameterDeclaration> indexParameters, MethodAttributes accessorAttributes, Func <MethodBodyCreationContext, Expression> getBodyProvider, Func <MethodBodyCreationContext, Expression> setBodyProvider) { ArgumentUtility.CheckNotNull("declaringType", declaringType); ArgumentUtility.CheckNotNullOrEmpty("name", name); ArgumentUtility.CheckNotNull("type", type); ArgumentUtility.CheckNotNull("indexParameters", indexParameters); // Get body provider may be null. // Set body provider may be null. MemberAttributesUtility.ValidateAttributes( "property accessor methods", MemberAttributesUtility.InvalidMethodAttributes, accessorAttributes, "accessorAttributes"); if (getBodyProvider == null && setBodyProvider == null) { throw new ArgumentException("At least one accessor body provider must be specified.", "getBodyProvider"); } var indexParams = indexParameters.ToList(); var signature = new PropertySignature(type, indexParams.Select(pd => pd.Type)); if (declaringType.AddedProperties.Any(p => p.Name == name && PropertySignature.Create(p).Equals(signature))) { throw new InvalidOperationException("Property with equal name and signature already exists."); } var attributes = accessorAttributes | MethodAttributes.SpecialName; MutableMethodInfo getMethod = null, setMethod = null; if (getBodyProvider != null) { getMethod = CreateAccessor(declaringType, "get_" + name, attributes, type, indexParams, getBodyProvider); } if (setBodyProvider != null) { var setterParams = indexParams.Concat(new[] { new ParameterDeclaration(type, "value") }); setMethod = CreateAccessor(declaringType, "set_" + name, attributes, typeof(void), setterParams, setBodyProvider); } return(new MutablePropertyInfo(declaringType, name, PropertyAttributes.None, getMethod, setMethod)); }