private void button1_Click(object sender, RoutedEventArgs e) { try { if (factory == null) { // Создание экземпляра ChannelFactory<T>, где Т - Контракт. factory = new ChannelFactory<IContract>(binding, new EndpointAddress(address)); // Использование factory для создания канала (прокси). channel = factory.CreateChannel(); } if (factory != null && channel != null) { textBox1.Text += "From Me: " + textBox2.Text + Environment.NewLine; // Использование channel (прокси) для отправки сообщения получателю. textBox1.Text += "From Server: " + channel.Say(textBox2.Text) + Environment.NewLine; textBox2.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public object Create(IContract contract) { var type = contract.GetValueOrDefault<TypeContract, Type>(); var name = contract.GetValueOrDefault<NameContract, string>(); return Create(type, name, contract); }
public static RollResultContractItem CalculateFutureResult(IContract contract, Func<FutureSeries, FutureStatic> getFutureFuc, Func<FutureSeries, string> getContractFunc, Func<FutureSeries, double> getBondPriceFunc) { var market = AsFuture(contract).BbgBase.Market(); var country = (BondAnalytics.Country) Enum.Parse(typeof(BondAnalytics.Country), market); // byran lim config coded in symmetry.net. we use this until we have a centralised place for the curve static var fcstCfg = new SpreadTimeSeriesConfigs(market, bForecastCurve: true); var discCfg = new SpreadTimeSeriesConfigs(market, bForecastCurve: false); var rollresults = contract.ContractSeries.Select(c => { var s = c as FutureSeries; if (s == null) return null; var forCurve = SymmetryDataModel.GetDiscountCurve(fcstCfg.SymForecastCurveName, c.Date); var disCurve = SymmetryDataModel.GetDiscountCurve(fcstCfg.SymDiscountCurveName, c.Date); var mms = BondCalc.CalcMeasure(CalcMeasure.MMS, getBondPriceFunc(s), country, getFutureFuc(s).FirstNoticeDate, disCurve, forCurve, DateTime.MinValue, s.CurrentFuture.Expiry, DateTime.MinValue, 0, 6, true, BondAnalytics.DayCountType.Act360, 12,12,null); var mmsSeries = new Tuple<DateTime, RollResultItem>(c.Date, new RollResultItem { Name = getContractFunc(s), Value = mms, }); return new {m = mmsSeries}; }).Where(x => x != null).ToArray(); return new RollResultContractItem { MMS = new DatedDataCollectionGen<RollResultItem>(rollresults.Select(r => r.m.Item1).ToArray(), rollresults.Select(r => r.m.Item2).ToArray()), }; }
public CustomerEditOrderPresenter(ICustomerEditOrderView view, IContract contract) { this.contract = contract; this.customerEditOrderView = view; this.customerEditOrderView.ShowOrderInfo(); CommandList = new CommandList(); }
public FirstNoticeCTDRollLogic(IContract identifier, CTDGenerator generator) : base(identifier) { this.generator = generator; // todo! how to decide the source of CTD ? //generator = new BloombergCTDGen(); }
public CustomerEditOrderForm(IContract contract) { InitializeComponent(); SetStrings(); presenter = new CustomerEditOrderPresenter(this, contract); Products = presenter.GetAllProducts().ToList(); }
public CommandListParser(IContract contract, CommandList commandList, ClientOrder order, User user) { this.contract = contract; this.commandList = commandList; this.order = order; this.user = user; }
public static bool ContractOwnsAppDomain(IContract contract, AppDomain domain) { if (domain == null) throw new ArgumentNullException("domain"); if (contract == null) throw new ArgumentNullException("contract"); System.Diagnostics.Contracts.Contract.EndContractBlock(); return domain.GetData(s_appDomainOwner) == contract; }
public ContractHandle(IContract contract) { if (contract == null) throw new ArgumentNullException("contract"); System.Diagnostics.Contracts.Contract.EndContractBlock(); m_contract = contract; m_token = m_contract.AcquireLifetimeToken(); }
public Account GetAccountByNumber(string pNumber, int pCurrencyId, IContract pContract, OBookingDirections pBookingDirection) { if (_accountingRules != null) { var specificAccount = _accountingRules.GetSpecificAccount(pNumber, pContract, pBookingDirection); if (specificAccount != null) pNumber = specificAccount.Number; } return _getAccountByNumber(pNumber, pCurrencyId); }
public static RollResults CalculateForwardCTD(IContract contract, bool smoothStart = false) { var market = AsFuture(contract).BbgBase.Market(); var computeTasks = new Task<RollResultContractItem>[5]; DateTime now = DateTime.Now; //var curResult = CalculateCTDResult(contract, f => f.CurrentCTD, f => f.CurrentContract, f => f.CurrentFuture.Value * f.CurrentConvFactor, smoothStart, true, f => f.CurrentFuture); //var prevResult = CalculateCTDResult(contract, f => f.PrevCTD, f => f.PrevContract, f => f.PrevFuture.Value * f.PrevConvFactor, smoothStart, true, f => f.PrevFuture); //var ooResult = CalculateCTDResult(contract, f => f.OOCTD, f => f.OOContract, f => f.OoFuture.Value * f.OOConvFactor, smoothStart, true, f => f.OoFuture); //var dResult = CalculateCTDResult(contract, f => f.dCTD, f => f.DContract, f => f.DFuture.Value * f.dConvFactor, smoothStart, true, f => f.DFuture); //var d2Result = CalculateCTDResult(contract, f => f.d2CTD, f => f.D2Contract, f => f.D2Future.Value * f.d2ConvFactor, smoothStart, true, f => f.D2Future); Log.InfoFormat("start computing forward ctd for {0}", contract.Ric); RollResultContractItem curResult = null; RollResultContractItem prevResult = null; RollResultContractItem ooResult = null; RollResultContractItem dResult = null; RollResultContractItem d2Result = null; computeTasks[0] = Task.Factory.StartNew(() => CalculateCTDResult(contract, f => f.CurrentCTD, f => f.CurrentContract, f => f.CurrentFuture.Value * f.CurrentConvFactor, smoothStart, true, f => f.CurrentFuture)).ContinueWith(r => curResult = r.Result); computeTasks[1] = Task.Factory.StartNew(() => CalculateCTDResult(contract, f => f.PrevCTD, f => f.PrevContract, f => f.PrevFuture.Value * f.PrevConvFactor, smoothStart, true, f => f.PrevFuture)).ContinueWith(r => prevResult = r.Result); computeTasks[2] = Task.Factory.StartNew(() => CalculateCTDResult(contract, f => f.OOCTD, f => f.OOContract, f => f.OoFuture.Value * f.OOConvFactor, smoothStart, true, f => f.OoFuture)).ContinueWith(r => ooResult = r.Result); computeTasks[3] = Task.Factory.StartNew(() => CalculateCTDResult(contract, f => f.dCTD, f => f.DContract, f => f.DFuture.Value * f.dConvFactor, smoothStart, true, f => f.DFuture)).ContinueWith(r => dResult = r.Result); computeTasks[4] = Task.Factory.StartNew(() => CalculateCTDResult(contract, f => f.d2CTD, f => f.D2Contract, f => f.D2Future.Value * f.d2ConvFactor, smoothStart, true, f => f.D2Future)).ContinueWith(r => d2Result = r.Result); Task.WaitAll(computeTasks.Cast<Task>().ToArray()); Log.InfoFormat("Finish computing all forward ctd series for {0} in {1}s", contract.Ric, (DateTime.Now - now).TotalSeconds); // get the last smooth result from carbon var moniker = ("symapp.roll.fctd." + market + "." + AsFuture(contract).BbgBase).ToLower(); var smooth = SmoothAllResultSeries(curResult, prevResult, smoothStart, moniker, r => r.CurrentResult, r => r.OResult); return new RollResults { Identifier = AsFuture(contract).BbgBase, RollType = "fctd", Market = market, CurrentResult = curResult, OResult = prevResult, OOResult = ooResult, SmoothResult = smooth, DResult = dResult, D2Result = d2Result, }; }
public static RollResults CalculateFuture(IContract contract) { var market = AsFuture(contract).BbgBase.Market(); var curResult = CalculateFutureResult(contract, f => f.CurrentFuture, f => f.CurrentContract, f => f.CurrentValue); var prevResult = CalculateFutureResult(contract, f => f.PrevFuture, f => f.PrevContract, f => f.PrevValue); return new RollResults { Identifier = AsFuture(contract).BbgBase, RollType = "future", Market = market, CurrentResult = curResult, OResult = prevResult, }; }
protected DateTime RollDatesEnrichment(IContract identifier, DateTime date) { switch (AsFuture().BbgBase) { case "RX": case "DU": case "OE": case "UB": // can add speical case for particular market return RollBackWeekdays(date, 1); default: return date; // -2 weekday from the first notice day } }
/// <summary> /// Attempt to resolve a realtionship from the given path. /// </summary> /// <param name="root">The root level contract to resolve the relationship from.</param> /// <param name="path">The path for to resolve on the relationship.</param> /// <param name="memberPath">The path that was resolved, or undefined if no path could be found.</param> /// <returns>true if the path was resolved correctly, false if not.</returns> bool TryResolve(IContract root, string path, ref MemberPath memberPath) { var index = path.IndexOf(".", StringComparison.Ordinal); if (index < 0) { var relationship = root.Relationship(path); if (relationship == null) { memberPath = null; return false; } memberPath = new MemberPath(relationship); return true; } return TryResolveRelationship(root, path.Substring(0, index), path.Substring(index + 1), ref memberPath); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); contract = SetConnection(); AuthenticationForm authForm = new AuthenticationForm(contract); CustomerOrdersForm custOrdersForm; CustomerEditOrderForm custEditOrdersForm; Application.Run(authForm); if (authForm.User == null) { //end of program return; } if (authForm.User.Role == Role.Customer) { custOrdersForm = new CustomerOrdersForm(contract); custOrdersForm.Customer = authForm.User; Application.Run(custOrdersForm); while (custOrdersForm.SelectedOrder != null) { custEditOrdersForm = new CustomerEditOrderForm(contract); custEditOrdersForm.Customer = custOrdersForm.Customer; custEditOrdersForm.Order = custOrdersForm.SelectedOrder; Application.Run(custEditOrdersForm); custOrdersForm = new CustomerOrdersForm(contract); custOrdersForm.Customer = authForm.User; Application.Run(custOrdersForm); } } else if (authForm.User.Role == Role.Technologist) { TechnologistForm TechForm = new TechnologistForm(contract); TechForm.Technologist = authForm.User; Application.Run(TechForm); } }
public static IRollLogic CreateRollLogic(IContract future, RollSettings rollsettings) { var futureContract = future as FutureContract; if (futureContract == null) return null; var rollcontrol = rollsettings.RollMethod ?? futureContract.ContractEnd; // if not roll method set use default switch (rollcontrol) { case RollControl.FirstNotice: return futureContract.HasCTD ? new FirstNoticeCTDRollLogic(future, CreateCtdGenerator(rollsettings.CTDSource)) : new FirstIssueFutureRollLogic(future); case RollControl.DeliveryDate: break; case RollControl.LastTrade: break; case RollControl.MonthEnd: return new MonthEndFutureRollLogic(future); default: throw new ArgumentOutOfRangeException(); } return null; }
public void FromItem(AGSSerializationContext context, IRoom item) { ID = item.ID; ShowPlayer = item.ShowPlayer; Background = context.GetContract(item.Background); Objects = new List <IContract <IObject> > (item.Objects.Count); foreach (var obj in item.Objects) { Objects.Add(context.GetContract(obj)); } Properties = context.GetContract(item.Properties); Areas = new List <IContract <IArea> > (item.Areas.Count); foreach (var area in item.Areas) { Areas.Add(context.GetContract(area)); } Edges = context.GetContract((IAGSEdges)item.Edges); }
// Requires the HAV and the transparent proxy to the add-in adapter, // which implements System.AddIn.Contract.IContract. internal void AssociateWithHostAddinView(Object hostAddinView, IContract contract) { System.Diagnostics.Contracts.Contract.Requires(hostAddinView != null); _contract = contract; // add weak reference on the HAV to our list _havReference = new WeakReference(hostAddinView); lock (_havLock) { HAVControllerPair havRef = new HAVControllerPair(hostAddinView, this); havRef._next = _havList; _havList = havRef; // clean up the list every so often _addInCountSinceLastPrune++; if (_addInCountSinceLastPrune == AddInCountSinceLastPruneLimit) { // searching for a non-exiting addin will have the desired effect // of pruning the list of any stale references. FindController(new Object(), false); _addInCountSinceLastPrune = 0; } } }
protected virtual void Dispose(bool disposing) { if (disposing) { // managed cleanup would go here } if (m_token != null) { try { // See comments in AddInController for why its OK to call into the // transparentProxy from this objects Finalize member. m_contract.RevokeLifetimeToken((int)m_token); } catch (AppDomainUnloadedException) { } catch (RemotingException) { } catch (SerializationException) {} finally { m_token = null; m_contract = null; } } }
/// <summary> /// Attempt to resolve a realtionship from the given name and path. /// </summary> /// <param name="root">The root level contract to resolve the relationship from.</param> /// <param name="name">The name of the relationship to resolve.</param> /// <param name="path">The path for to resolve on the relationship.</param> /// <param name="memberPath">The path that was resolved, or undefined if no path could be found.</param> /// <returns>true if the path was resolved correctly, false if not.</returns> bool TryResolveRelationship(IContract root, string name, string path, ref MemberPath memberPath) { var relationship = root.Relationship(name); if (relationship == null) { memberPath = null; return false; } if (_contractResolver.TryResolve(relationship.RelatedTo, out root) == false) { memberPath = null; return false; } if (TryResolve(root, path, ref memberPath) == false) { return false; } memberPath = new MemberPath(relationship, memberPath); return true; }
public MainWindow() { ip = "localhost"; InitializeComponent(); buttonImageSelect.IsEnabled = true; labelControl = new ProgressChecker(); labelProgress.DataContext = labelControl; labelControl.Progress = "prgress precent"; imageControl = new ImageChecker(); boxImageShow.DataContext = imageControl; NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false); binding.MaxBufferSize = int.MaxValue; binding.MaxReceivedMessageSize = int.MaxValue; factory = new ChannelFactory <IContract>(binding, new EndpointAddress($"net.tcp://{ip}:12345/srv")); client = factory.CreateChannel(); try { string[] filters = client.GetFilters(); foreach (var filter in filters) { comboBoxFilter.Items.Add(filter); } if (filters.Length < 1) { throw new Exception("No Filters found"); } comboBoxFilter.SelectedItem = comboBoxFilter.Items[0]; buttonImageSelect.IsEnabled = true; } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public void TestGasInjector_ContractMethodWithRecursion_GasInjectionSucceeds() { ContractCompilationResult compilationResult = ContractCompiler.CompileFile("SmartContracts/Recursion.cs"); Assert.True(compilationResult.Success); byte[] originalAssemblyBytes = compilationResult.Compilation; var callData = new MethodCall(nameof(Recursion.DoRecursion)); IContractModuleDefinition module = this.moduleReader.Read(originalAssemblyBytes).Value; module.Rewrite(this.rewriter); CSharpFunctionalExtensions.Result <IContractAssembly> assembly = this.assemblyLoader.Load(module.ToByteCode()); assembly.Value.SetObserver(new Observer(this.gasMeter, new MemoryMeter(10000))); IContract contract = Contract.CreateUninitialized(assembly.Value.GetType(module.ContractType.Name), this.state, null); IContractInvocationResult result = contract.Invoke(callData); Assert.True(result.IsSuccess); Assert.True(this.gasMeter.GasConsumed > 0); }
ImportingConstructorWithCustomImportingConstructor([Import] IContract argument) { }
public ContractAdapterImplementation(IContract contract) { this.Contract = contract; }
public RemoteArgument(IContract value, bool isByRef) { this._value = value; this.remoteArgKind = RemoteArgumentKind.Contract; this.intrinsicTypeCode = TypeCode.Object; this.isByRef = isByRef; }
/// <summary> /// Sets the selected thread id. /// There must not already be a selected thread id. /// </summary> /// <param name="tid">thread id to be set to selected</param> /// <param name="contract">IContract</param> public void SetSelected(int tid, IContract contract) { contract.Assert(SelectedEntry < 0); contract.Assert(tid >= 0 && tid < List.Count); SelectedEntry = tid; }
/// <summary> /// Get a nondet choice. /// This may replay a nondet choice or make (and record) a new nondet choice. /// </summary> /// <param name="isBoolChoice">If true, a boolean choice; otherwise, an int choice.</param> /// <param name="rand">Random</param> /// <param name="contract">IContract</param> public int MakeOrReplayNondetChoice(bool isBoolChoice, IRandomNumberGenerator rand, IContract contract) { contract.Assert( rand != null || isBoolChoice, "A DFS DPOR exploration of int nondeterminstic choices " + "is not currently supported because this won't scale."); if (NondetChoices == null) { NondetChoices = new List <NonDetChoice>(); } if (NextNondetChoiceIndex < NondetChoices.Count) { // Replay: NonDetChoice choice = NondetChoices[NextNondetChoiceIndex]; ++NextNondetChoiceIndex; contract.Assert(choice.IsBoolChoice == isBoolChoice); return(choice.Choice); } // Adding a choice. contract.Assert(NextNondetChoiceIndex == NondetChoices.Count); NonDetChoice ndc = new NonDetChoice { IsBoolChoice = isBoolChoice, Choice = rand == null ? 0 : (isBoolChoice ? rand.Next(2) : rand.Next()) }; NondetChoices.Add(ndc); ++NextNondetChoiceIndex; return(ndc.Choice); }
protected virtual object Create(Type type, string name, IContract contract) { IMethodDescriptor create = this.Reflection().FindDescriptor("GenericCreate").Close(type) as IMethodDescriptor; return(create.Invoke(this, name, contract)); }
public void Shutdown() { // Disables usage of the add-in, by breaking the pipeline. // Also, if we own the appdomain, we unload it. lock (this) // Ensure multiple threads racing on Shutdown don't collide. { AddInEnvironment environment = _addInEnvironment; if (environment != null) { try { if (_contract != null) { Object hav = _havReference.Target; IDisposable disposableHAV = hav as IDisposable; if (disposableHAV != null) { try { disposableHAV.Dispose(); } catch (AppDomainUnloadedException e) { Log(e.ToString()); } catch (RemotingException re) { Log(re.ToString()); } catch (SerializationException se) { Log(se.ToString()); } } IDisposable disposableContract = _contract as IDisposable; if (disposableContract != null) { try { disposableContract.Dispose(); } catch (AppDomainUnloadedException e) { Log(e.ToString()); } catch (RemotingException re) { Log(re.ToString()); } catch (SerializationException se) { Log(se.ToString()); } } _contract = null; } if (_activationWorker != null) { // Unhook an assembly resolve event in the target appdomain. // However, if one of the adapters implemented IDisposable and cleaned // up the appropriate lifetime tokens, this appdomain may be unloading // already (we launch another thread to do this, so we are guaranteed // to have a benign race condition). We should catch an // AppDomainUnloadedException here. try { _activationWorker.Dispose(); } catch (AppDomainUnloadedException) { } catch (RemotingException) { } catch (SerializationException) { } _activationWorker = null; } } finally { if (_unloadDomainOnExit) { // AppDomain.Unload will block until we have finalized all // objects within the appdomain. Also, this may already // have been unloaded. try { environment.UnloadAppDomain(); } catch (AppDomainUnloadedException) { } catch (RemotingException) { } // Using the transparent proxy will now cause exceptions, // as managed threads are not allowed to enter this appdomain. } } _addInEnvironment = null; // eagerly remove from list lock (_havLock) { Object addin = _havReference.Target; if (addin != null) FindController(addin, true); } // The perf team recommends doing a GC after a large amount of memory has // been dereferenced. We wait for the finalizers to complete first // becase some references in the addin are not released until finalization. // Also, if an addin is buggy and causes the finalizer thread to hang, // waiting here makes it fail deterministically. System.GC.WaitForPendingFinalizers(); System.GC.Collect(); } // end if domain != null else { throw new InvalidOperationException(Res.AppDomainNull); } } }
/// <summary> /// The name of the field. /// </summary> /// <param name="contract">The contract that the field belongs to.</param> /// <param name="name">The name of the field.</param> internal RuntimeField(IContract contract, string name) { Contract = contract; Name = name; }
protected virtual void ExtractContract(IContract contract, out Type type, out string name) { type = contract.GetValueOrDefault <TypeContract, Type>(); name = contract.GetValueOrDefault <NameContract, string>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="contractResolver">The contract resolver to resolve with.</param> /// <param name="root">The root level contact to parse from, or null if parsing a full path.</param> internal MemberPathResolver(IContractResolver contractResolver, IContract root) { _contractResolver = contractResolver; _root = root; }
public LimitsToDmg(IContract <T> contract) : base(contract) { }
/// <summary> /// Creates a new instance of a smart contract by invoking the contract's constructor /// </summary> public VmExecutionResult Create(IStateRepository repository, ISmartContractState contractState, RuntimeObserver.IGasMeter gasMeter, byte[] contractCode, object[] parameters, string typeName = null) { string typeToInstantiate; ContractByteCode code; // Decompile the contract execution code Result <IContractModuleDefinition> moduleResult = this.moduleDefinitionReader.Read(contractCode); if (moduleResult.IsFailure) { this.logger.LogTrace(moduleResult.Error); this.logger.LogTrace("(-)[CONTRACT_BYTECODE_INVALID]"); return(VmExecutionResult.Fail(VmExecutionErrorKind.LoadFailed, "Contract bytecode is not valid IL.")); } // Validate contract execution code using (IContractModuleDefinition moduleDefinition = moduleResult.Value) { SmartContractValidationResult validation = moduleDefinition.Validate(this.validator); // If validation failed, refund the sender any remaining gas. if (!validation.IsValid) { this.logger.LogTrace("(-)[CONTRACT_VALIDATION_FAILED]"); return(VmExecutionResult.Fail(VmExecutionErrorKind.ValidationFailed, new SmartContractValidationException(validation.Errors).ToString())); } typeToInstantiate = typeName ?? moduleDefinition.ContractType.Name; var observer = new Observer(gasMeter, new MemoryMeter(MemoryUnitLimit)); var rewriter = new ObserverRewriter(observer); if (!this.Rewrite(moduleDefinition, rewriter)) { return(VmExecutionResult.Fail(VmExecutionErrorKind.RewriteFailed, "Rewrite module failed")); } Result <ContractByteCode> getCodeResult = this.GetByteCode(moduleDefinition); if (!getCodeResult.IsSuccess) { return(VmExecutionResult.Fail(VmExecutionErrorKind.RewriteFailed, "Serialize module failed")); } code = getCodeResult.Value; } Result <IContract> contractLoadResult = this.Load( code, typeToInstantiate, contractState.Message.ContractAddress.ToUint160(), contractState); if (!contractLoadResult.IsSuccess) { return(VmExecutionResult.Fail(VmExecutionErrorKind.LoadFailed, contractLoadResult.Error)); } IContract contract = contractLoadResult.Value; this.LogExecutionContext(contract.State.Block, contract.State.Message, contract.Address); // Set the code and the Type before the method is invoked repository.SetCode(contract.Address, contractCode); repository.SetContractType(contract.Address, typeToInstantiate); // Invoke the constructor of the provided contract code IContractInvocationResult invocationResult = contract.InvokeConstructor(parameters); if (!invocationResult.IsSuccess) { this.logger.LogTrace("[CREATE_CONTRACT_INSTANTIATION_FAILED]"); return(GetInvocationVmErrorResult(invocationResult)); } this.logger.LogTrace("[CREATE_CONTRACT_INSTANTIATION_SUCCEEDED]"); return(VmExecutionResult.Ok(invocationResult.Return, typeToInstantiate)); }
public IEnumerable <Call> Calls(IContract contract) { return(_callLog .Where(c => (c.SourcePortId.Equals(contract.Port.PortId) || c.DestinationPortId.Equals(contract.Port.PortId)) && c.Duration != TimeSpan.Zero)); }
/// <summary> /// A person considered by the court to be without the capacity to contract /// </summary> public ByMentalIncompetent(IContract <T> contract) : base(contract) { }
ImportingConstructorWithCustomImportingConstructorAllowMultiple([Import] IContract argument) { }
internal IContract GetContract() { if (_contract != null) return _contract; // in direct connect, the contract has not been created. Create it now. Object hav = _havReference.Target; if (hav == null) throw new InvalidOperationException(Res.AddInNoLongerAvailable); // Assert permission to the contracts, AddInSideAdapters, AddInViews and specific Addin directories only. PermissionSet permissionSet = new PermissionSet(PermissionState.None); permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery, Path.Combine(_token.PipelineRootDirectory, AddInStore.ContractsDirName))); permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery, Path.Combine(_token.PipelineRootDirectory, AddInStore.AddInAdaptersDirName))); permissionSet.Assert(); Assembly.LoadFrom(_token._contract.Location); Assembly addinAdapterAssembly = Assembly.LoadFrom(_token._addinAdapter.Location); CodeAccessPermission.RevertAssert(); // Create the AddIn adapter for the addin ActivationWorker worker = new ActivationWorker(_token); _contract = worker.CreateAddInAdapter(hav, addinAdapterAssembly); return _contract; }
protected virtual bool CanFullfill(Type type, string name, IContract contract) { return(false); }
public TechnologistForm(IContract contract) { InitializeComponent(); presenter = new TechnologistPresenter(this, contract); repositoryItemComboBox1.Items.AddRange(Enum.GetValues((typeof(Status)))); }
protected virtual T GenericCreate <T>(string name, IContract contract) { throw new NotImplementedException(); }
public ContractTier(IContract contractsRepository) { this.contractsRepository = contractsRepository; }
/// <summary> /// 获取合同签约年度列表 /// </summary> /// <returns></returns> public List <string> GetSignYearList() { IContract dal = baseDal as IContract; return(dal.GetSignYearList()); }
/// <summary> /// Deselect the selected thread. /// </summary> /// <param name="contract">IContract</param> public void ClearSelected(IContract contract) { SelectedEntry = -1; }
/// <summary> /// Add a thread to the backtrack set. /// </summary> /// <param name="tid">a thread id to add</param> /// <param name="contract">IContract</param> public void AddToBacktrack(int tid, IContract contract) { List[tid].Backtrack = true; contract.Assert(List[tid].Enabled); }
private static IEnumerable <Test> GetContractVerificationTests(IContract contract, IFieldInfo field) { var context = new ContractVerificationContext(field); return(contract.GetContractVerificationTests(context)); }
protected virtual object Create(Type type, string name, IContract contract) { throw new NotImplementedException(); }
public MyEmptyClassWithStandardConstructor([Import] IContract myProperty) { this.MyProperty = myProperty; }
public CustomerOrdersForm(IContract contract) { InitializeComponent(); SetStrings(); presenter = new CustomerOrdersPresenter(this, contract); }
public IEnumerable <Payment> Payments(IContract contract) { return(_payments.Where(p => p.Contract.Equals(contract)).ToArray()); }
/// <summary> /// Constructor. /// </summary> /// <param name="contract">The contract available to the resolver.</param> public ContractResolver(IContract contract) : this(new [] { contract }) { }
/// <summary> /// Creates a new instance of a smart contract by invoking the contract's constructor /// </summary> public VmExecutionResult Create(IStateRepository repository, ISmartContractState contractState, byte[] contractCode, object[] parameters, string typeName = null) { this.logger.LogTrace("()"); string typeToInstantiate; ContractByteCode code; // Decompile the contract execution code Result <IContractModuleDefinition> moduleResult = this.moduleDefinitionReader.Read(contractCode); if (moduleResult.IsFailure) { this.logger.LogTrace("(-)[CONTRACT_BYTECODE_INVALID]"); return(VmExecutionResult.Error(new ContractErrorMessage("Contract bytecode is not valid IL."))); } // Validate contract execution code using (IContractModuleDefinition moduleDefinition = moduleResult.Value) { SmartContractValidationResult validation = moduleDefinition.Validate(this.validator); // If validation failed, refund the sender any remaining gas. if (!validation.IsValid) { this.logger.LogTrace("(-)[CONTRACT_VALIDATION_FAILED]"); // TODO: List errors by string. return(VmExecutionResult.Error(new ContractErrorMessage(new SmartContractValidationException(validation.Errors).ToString()))); } typeToInstantiate = typeName ?? moduleDefinition.ContractType.Name; var observer = new Observer(contractState.GasMeter, MemoryUnitLimit); var rewriter = new ObserverRewriter(observer); moduleDefinition.Rewrite(rewriter); code = moduleDefinition.ToByteCode(); } Result <IContract> contractLoadResult = this.Load( code, typeToInstantiate, contractState.Message.ContractAddress.ToUint160(this.network), contractState); if (!contractLoadResult.IsSuccess) { LogErrorMessage(contractLoadResult.Error); this.logger.LogTrace("(-)[LOAD_CONTRACT_FAILED]"); return(VmExecutionResult.Error(new ContractErrorMessage(contractLoadResult.Error))); } IContract contract = contractLoadResult.Value; LogExecutionContext(this.logger, contract.State.Block, contract.State.Message, contract.Address); // Set the code and the Type before the method is invoked repository.SetCode(contract.Address, contractCode); repository.SetContractType(contract.Address, typeToInstantiate); // Invoke the constructor of the provided contract code IContractInvocationResult invocationResult = contract.InvokeConstructor(parameters); if (!invocationResult.IsSuccess) { this.logger.LogTrace("[CREATE_CONTRACT_INSTANTIATION_FAILED]"); return(VmExecutionResult.Error(invocationResult.ErrorMessage)); } this.logger.LogTrace("[CREATE_CONTRACT_INSTANTIATION_SUCCEEDED]"); this.logger.LogTrace("(-):{0}={1}", nameof(contract.Address), contract.Address); return(VmExecutionResult.Success(invocationResult.Return, typeToInstantiate)); }
/// <summary> /// Attempt to resolve the resource contract from a CLR type. /// </summary> /// <param name="type">The CLR type of the resource contract to resolve.</param> /// <param name="contract">The resource contract that was associated with the given CLR type.</param> /// <returns>true if the resource contract could be resolved, false if not.</returns> public bool TryResolve(Type type, out IContract contract) { contract = _contracts.SingleOrDefault(t => t.ClrType == type); return contract != null; }
public Reliance(IContract <T> contract) : base(contract) { }
/// <summary> /// Attempt to resolve the resource contract from a resource type name. /// </summary> /// <param name="name">The resource type name of the resource contract to resolve.</param> /// <param name="contract">The resource contract that was associated with the given resource type name.</param> /// <returns>true if the resource contract could be resolved, false if not.</returns> public bool TryResolve(string name, out IContract contract) { contract = _contracts.SingleOrDefault(t => String.Equals(t.Name, name, StringComparison.OrdinalIgnoreCase)); return contract != null; }
public bool RemoteEquals(IContract contract) { return(m_Upstream.RemoteEquals(contract)); }
/// <summary> /// Tries to get the single selected thread. /// </summary> /// <param name="contract">IContract</param> /// <returns>The selected thread index or -1 if no thread is selected.</returns> public int TryGetSelected(IContract contract) { return(SelectedEntry); }
public PerfectTender(IContract <T> contract) : base(contract) { }
/// <summary> /// Are no threads selected? /// </summary> /// <param name="contract">IContract</param> public bool IsNoneSelected(IContract contract) { return(TryGetSelected(contract) < 0); }