public PackageRuleHandler(ITargetFrameworkProvider targetFrameworkProvider) { Requires.NotNull(targetFrameworkProvider, nameof(targetFrameworkProvider)); TargetFrameworkProvider = targetFrameworkProvider; }
public override void SetFileAttributes(IFileInfo file, FileAttributes fileAttributes) { Requires.NotNull("file", file); FileWrapper.Instance.SetAttributes(GetActualPath(file), fileAttributes); }
/// <summary> /// <para>Initializes a new instance of the <see cref="System.Fabric.Description.ServiceHealthQueryDescription" /> class.</para> /// </summary> /// <param name="serviceName"> /// <para>The service name. Cannot be null.</para> /// </param> /// <exception cref="System.ArgumentNullException"> /// <para>A null value was passed in for a required parameter.</para> /// </exception> public ServiceHealthQueryDescription(Uri serviceName) { Requires.Argument <Uri>("serviceName", serviceName).NotNull(); this.ServiceName = serviceName; }
public OperationDataFactoryWrapper(NativeRuntime.IOperationDataFactory operationDataFactory) { Requires.Argument("operationDataFactory", operationDataFactory).NotNull(); this.operationDataFactory = operationDataFactory; }
/// <summary> /// This is the core to find the continuation delegate(s) inside the given async state machine. /// The chain of objects is like this: async state machine -> async method builder -> task -> continuation object -> action. /// </summary> /// <remarks> /// There are 3 types of "async method builder": AsyncVoidMethodBuilder, AsyncTaskMethodBuilder, AsyncTaskMethodBuilder<T>. /// We don't cover AsyncVoidMethodBuilder as it is used rarely and it can't be awaited either; /// AsyncTaskMethodBuilder is a wrapper on top of AsyncTaskMethodBuilder<VoidTaskResult>. /// </remarks> private static IEnumerable <Delegate> FindContinuationDelegates(IAsyncStateMachine stateMachine) { Requires.NotNull(stateMachine, nameof(stateMachine)); var builder = GetStateMachineFieldValueOnSuffix(stateMachine, "__builder"); if (builder == null) { yield break; } var task = GetFieldValue(builder, "m_task"); if (task == null) { // Probably this builder is an instance of "AsyncTaskMethodBuilder", so we need to get its inner "AsyncTaskMethodBuilder<VoidTaskResult>" builder = GetFieldValue(builder, "m_builder"); if (builder != null) { task = GetFieldValue(builder, "m_task"); } } if (task == null) { yield break; } // "task" might be an instance of the type deriving from "Task", but "m_continuationObject" is a private field in "Task", // so we need to use "typeof(Task)" to access "m_continuationObject". var continuationField = typeof(Task).GetTypeInfo().GetDeclaredField("m_continuationObject"); if (continuationField == null) { yield break; } var continuationObject = continuationField.GetValue(task); if (continuationObject == null) { yield break; } if (continuationObject is IEnumerable items) { foreach (var item in items) { var action = item as Delegate ?? GetFieldValue(item, "m_action") as Delegate; if (action != null) { yield return(action); } } } else { var action = continuationObject as Delegate ?? GetFieldValue(continuationObject, "m_action") as Delegate; if (action != null) { yield return(action); } } }
internal ObjectPool(Func <T> factory, int size) { Requires.Argument(size >= 1, nameof(size), "must be greater than or equal to one"); _factory = factory; _items = new Element[size - 1]; }
/// <summary> /// update an existing IP filter /// </summary> /// <param name="ipFilter">filter details</param> public void UpdateIPFilter(IPFilterInfo ipFilter) { Requires.NotNull("ipFilter", ipFilter); DataProvider.Instance().UpdateIPFilter(ipFilter.IPFilterID, ipFilter.IPAddress, ipFilter.SubnetMask, ipFilter.RuleType, UserController.Instance.GetCurrentUserInfo().UserID); }
protected PartDiscovery(Resolver resolver) { Requires.NotNull(resolver, nameof(resolver)); this.Resolver = resolver; }
/// <summary> /// Checks whether an import many collection is creatable. /// </summary> internal static bool IsImportManyCollectionTypeCreateable(ImportDefinitionBinding import) { Requires.NotNull(import, nameof(import)); return(IsImportManyCollectionTypeCreateable(import.ImportingSiteType, import.ImportingSiteTypeWithoutCollection)); }
/// <summary> /// Decodes the specified value. /// </summary> /// <param name="value">The string value carried by the transport. Guaranteed to never be null, although it may be empty.</param> /// <returns>The deserialized form of the given string.</returns> /// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception> public object Decode(string value) { Requires.NotNull(value, "value"); return new Realm(value); }
/// <summary> /// Encodes the specified value as the original value that was formerly decoded. /// </summary> /// <param name="value">The value. Guaranteed to never be null.</param> /// <returns>The <paramref name="value"/> in string form, ready for message transport.</returns> public string EncodeAsOriginalString(object value) { Requires.NotNull(value, "value"); return ((Realm)value).OriginalString; }
/// <summary> /// Encodes the specified value. /// </summary> /// <param name="value">The value. Guaranteed to never be null.</param> /// <returns>The <paramref name="value"/> in string form, ready for message transport.</returns> public string Encode(object value) { Requires.NotNull(value, "value"); return value.ToString(); }
/// <summary> /// Asserts that an object is of the given <see cref="Type"/>. /// </summary> /// <param name="value">The value to be tested.</param> /// <param name="expectedType">The expected <see cref="Type"/>.</param> public static void IsType(object value, Type expectedType) { Requires.NotNull(value, "value"); TypeAssert.IsType(value, expectedType, Strings.Assertion_WrongType, expectedType, value.GetType()); }
/// <summary> /// Begins a new scope for the given <paramref name="container"/>. /// Services, registered using the <see cref="ThreadScopedLifestyle"/> are cached during the /// lifetime of that scope. The scope should be disposed explicitly. /// </summary> /// <param name="container">The container.</param> /// <returns>A new <see cref="Scope"/> instance.</returns> /// <exception cref="ArgumentNullException"> /// Thrown when the <paramref name="container"/> is a null reference.</exception> /// <example> /// <code lang="cs"><![CDATA[ /// using (ThreadScopedLifestyle.BeginScope()) /// { /// var handler = (IRequestHandler)container.GetInstance(handlerType); /// /// handler.Handle(request); /// } /// ]]></code> /// </example> public static Scope BeginScope(Container container) { Requires.IsNotNull(container, nameof(container)); return(GetScopeManager(container).BeginScope()); }
public virtual Requires VisitRequires (Requires node) { if (node == null) return null; node.Assertion = VisitExpression (node.Assertion); node.UserMessage = VisitExpression (node.UserMessage); return node; }
internal CombinedPartDiscovery(IReadOnlyList <PartDiscovery> discoveryMechanisms) : base(Resolver.DefaultInstance) { Requires.NotNull(discoveryMechanisms, nameof(discoveryMechanisms)); this.discoveryMechanisms = discoveryMechanisms; }
internal void CheckPrecondition(Requires req) { if (req == null) return; this.hasError = false; this.Current = req; this.Visit(req); }
public override bool IsExportFactoryType(Type type) { Requires.NotNull(type, nameof(type)); return(this.discoveryMechanisms.Any(discovery => discovery.IsExportFactoryType(type))); }
public CatalogReflectionContextAttribute(Type reflectionContextType) { Requires.NotNull(reflectionContextType, "reflectionContextType"); _reflectionContextType = reflectionContextType; }
/// <summary> /// Reflects over an assembly and produces MEF parts for every applicable type. /// </summary> /// <param name="assembly">The assembly to search for MEF parts.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A set of generated parts.</returns> public Task <DiscoveredParts> CreatePartsAsync(Assembly assembly, CancellationToken cancellationToken = default(CancellationToken)) { Requires.NotNull(assembly, nameof(assembly)); return(this.CreatePartsAsync(new[] { assembly }, null, cancellationToken)); }
public void DeleteIPFilter(IPFilterInfo ipFilter) { Requires.PropertyNotNegative("ipFilter", "ipFilter.IPFilterID", ipFilter.IPFilterID); DataProvider.Instance().DeleteIPFilter(ipFilter.IPFilterID); }
public DesignTimeAssemblyResolution(IUnconfiguredProjectVsServices projectVsServices) { Requires.NotNull(projectVsServices, nameof(projectVsServices)); _projectVsServices = projectVsServices; }
private static string GetAwaiterId(Awaiter awaiter) { Requires.NotNull(awaiter, nameof(awaiter)); return(awaiter.GetHashCode().ToString(CultureInfo.InvariantCulture)); }
public CompositionExceptionDebuggerProxy(CompositionException exception) { Requires.NotNull(exception, "exception"); this._exception = exception; }
public override bool IsInSync(IFileInfo file) { Requires.NotNull("file", file); return(Convert.ToInt32((file.LastModificationTime - GetLastModificationTime(file)).TotalSeconds) == 0); }
public ExternalDuplicateWithSuffixByNameAttribute(string suffix) { Requires.NotNullOrEmpty(suffix, nameof(suffix)); this.Suffix = suffix; }
public FileHelpersDataReader(Type type) { Requires.NotNull(type, "type"); this.type = type; }
public UserAgentHandler(ProductHeaderValue product) { Requires.ArgumentNotNull(product, nameof(product)); _userAgentHeaderValues = GetUserAgentHeaderValues(product); }
/// <summary> /// Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. This is /// standard procedure in BitCoin. The resulting hash is in big endian form. /// </summary> internal static byte[] DoubleDigest(byte[] input) { Requires.NotNull(input, "input"); return(DoubleDigest(input, 0, input.Length)); }
public AggregateDiscriminatedUnionGenerator(params IDiscriminatedUnionGenerator <T>[] innerGenerators) { Requires.NotNull(innerGenerators, nameof(innerGenerators)); _innerGenerators = innerGenerators; }
public virtual void VisitRequires (Requires node) { if (node == null) return; VisitExpression (node.Assertion); VisitExpression (node.UserMessage); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="stateGraph">The state graph that should be built up.</param> public StateGraphBuilder(StateGraph <TExecutableModel> stateGraph) { Requires.NotNull(stateGraph, nameof(stateGraph)); _stateGraph = stateGraph; }
public static void Transform(ExtractorVisitor parent, Property autoProp, Invariant invariant, out Requires req, out Ensures ens) { var makeReq = new ChangePropertyInvariantIntoRequiresEnsures(parent, autoProp); req = makeReq.MakeRequires(invariant.Condition); var makeEns = new ChangePropertyInvariantIntoRequiresEnsures(parent, autoProp); ens = makeEns.MakeEnsures(invariant.Condition); ens.SourceContext = invariant.SourceContext; ens.PostCondition.SourceContext = ens.SourceContext; ens.ILOffset = invariant.ILOffset; if (ens.SourceConditionText == null) { ens.SourceConditionText = invariant.SourceConditionText; } req.SourceContext = invariant.SourceContext; req.Condition.SourceContext = req.SourceContext; req.ILOffset = invariant.ILOffset; if (req.SourceConditionText == null) { req.SourceConditionText = invariant.SourceConditionText; } }
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { Requires.NotNull(info, "info"); GetObjectData(info, context); }
private void CheckRequires(Method method, Requires requires) { // F: Contract.Requires(requires != null); Contract.Requires(method != null); CheckRequiresPlain(method, requires as RequiresPlain); var nonVisible = this.visibilityHelper.AsVisibleAs(requires.Condition, method); if (nonVisible != null) { string message = "Member '" + nonVisible.FullName + "' has less visibility than the enclosing method '" + method.FullName + "'."; this.HandleError(method, 1038, message, requires); } }
/// <summary> /// Processes operation contract statement node. /// </summary> /// <param name="node">The node.</param> private void Process_OperationContractStatement(dynamic node) { if (node.GetBrand() == "Ensures") { Ensures ensures = new Ensures(); // Map source location and node to object ensures.AddMetaInfo(new SourceLocationInfo(node, context)); context.AddObject(node, ensures); // OperationContract ensures.OperationContract = (OperationContract)NameContext.Current.Scope; // Text ensures.Text = node.Text; // Rule ensures.Rule = this.Process(node.Rule); ensures.Rule.ExpectedType = BuiltInType.Bool; } if (node.GetBrand() == "Requires") { Requires requires = new Requires(); // Map source location and node to object requires.AddMetaInfo(new SourceLocationInfo(node, context)); context.AddObject(node, requires); // OperationContract requires.OperationContract = (OperationContract)NameContext.Current.Scope; // Text requires.Text = node.Text; // Rule requires.Rule = this.Process(node.Rule); requires.Rule.ExpectedType = BuiltInType.Bool; // Otherwise requires.Otherwise = this.Process(node.Otherwise); requires.Otherwise.ExpectedType = PseudoType.Object; } }