Exemplo n.º 1
0
        public static IWorker wrap(IInterface face)
        {
            Client_Interface o = new Client_Interface(face);
            NObject obj = new NObject();
            WorkerBuilder builder = new WorkerBuilder(
            Bridge.stdn_Interface, obj, new IWorker[]{} );

            builder.addMethod(
            new Identifier("equals?"),
            new Function_Native(
                new ParameterImpl[]{
                    new ParameterImpl(
                        Direction.IN,
                        new NType(Bridge.stdn_Interface),
                        new Identifier("value"),
                        null )
                },
                new NType(Bridge.stdn_Interface),
                delegate(IScope args) {
                    return Bridge.toClientBoolean(
                        o.equals(
                            Bridge.toNativeInterface(
                                GE.evalIdent(args, "value"))));
                },
                null ));

            IWorker rv = builder.compile();
            rv.nativeObject = face;
            obj.rootWorker = rv;
            return rv;
        }
Exemplo n.º 2
0
 public Method(Identifier name, IInterface face)
 {
     Debug.Assert(name != null);
     Debug.Assert(face != null);
     _name = name;
     _face = face;
 }
Exemplo n.º 3
0
 public static IWorker cast(IWorker source, IInterface face)
 {
     if( inheritsOrIs(source.face, face) )
     return castDown(source, face);
     source = source.owner.rootWorker;
     if( inheritsOrIs(source.face, face) )
     return castDown(source, face);
     throw new ClientException("the object does not implement this interface");
 }
        /// <inheritdoc />
        public NetworkEntity AddInterface(IInterface iface)
        {
            if (this.interfaces.Values.Contains (iface))
                throw new NetworkContainsInterfaceException (iface.Name);

            var id = this.id_interfaces.GetNext ();
            this.interfaces.Add (id, iface);
            return new NetworkEntity (id);
        }
Exemplo n.º 5
0
 public static IWorker castDown(IWorker source, IInterface face)
 {
     Debug.Assert(inheritsOrIs(source.face, face));
     if( source.face == face )
     return source;
     foreach( IWorker child in source.childWorkers )
     if( inheritsOrIs(child.face, face) )
         return castDown(child, face);
     throw new ClientException("the object does not implement this interface");
 }
Exemplo n.º 6
0
        public void Init()
        {
            l.Debug("Инициирую TEST_bot_BackTestHost.Plugin");
            interf = Core.GetGlobal("Interface") as IInterface;

            if (interf != null)
            {
                interf.AddMenuItem("Роботы", "Бэктестинг", null, menu_Click);
            }
        }
Exemplo n.º 7
0
        public void Init()
        {
            l.Debug("Инициирую RndDataSource");
            interf = Core.GetGlobal("Interface") as IInterface;

            if (interf != null)
            {
                interf.AddMenuItem("Данные", "Загрузка с Finam.ru", null, menu_LoadFromFinam);
                interf.AddMenuItem("Данные", "Загрузка всех csv из папки", null, menu_LoadCSV);
            }
        }
Exemplo n.º 8
0
 public WorkerBase(WorkerBase data)
 {
     _face = data._face;
     _owner = data._owner;
     _childWorkers = data._childWorkers;
     _breeders = data._breeders;
     _callees = data._callees;
     _propGetters = data._propGetters;
     _propSetters = data._propSetters;
     _methods = data._methods;
 }
Exemplo n.º 9
0
 public Engine(IRenderer renderer, IInterface userInterface, IGameInitializationStrategy gameInitializationStrategy)
 {
     this.renderer = renderer;
     this.userInterface = userInterface;
     this.gameInitializationStrategy = gameInitializationStrategy;
     this.ships = new List<IShip>();
     this.hiddenGrid = new Grid();
     this.visibleGrid = new Grid();
     this.totalAttempts = 0;
     this.gameStatus = GameStatus.Play;
 }
        private double ExecuteInterface(IInterface something)
        {
            var stopwatch = Stopwatch.StartNew();
            something.Execute();
            stopwatch.Stop();

            var ticks = stopwatch.ElapsedTicks;
            var nanoseconds = GetNanoseconds(ticks);

            return nanoseconds;
        }
Exemplo n.º 11
0
        public void Init()
        {
            l.Debug("Инициирую");

            interf = Core.GetGlobal("Interface") as IInterface;

            if (interf != null)
            {
                interf.AddMenuItem("Логи", "Отобразить логи", null, item1_Click);
            }
        }
Exemplo n.º 12
0
 public void addBreeder(IInterface face, PropGetFunc func)
 {
     _breeders.Add(
     face,
     new Function_Native(
         new ParameterImpl[]{},
         new NType(face),
         delegate(IScope scope) {
             return func();
         },
         null));
 }
Exemplo n.º 13
0
        public void Init()
        {
            l.Debug("Инициирую RndDataSource");
            interf = Core.GetGlobal("Interface") as IInterface;

            if (interf != null)
            {
                interf.AddMenuItem("Данные", "Тестовые тики", "Генератор ровных баров", item1_Click);
                interf.AddMenuItem("Данные", "Тестовые тики", "Отправить тик в ручную", item2_Click);
                interf.AddMenuItem("Данные", "Тестовые тики", "Генератор случайных тиков", item3_Click);
            }
        }
Exemplo n.º 14
0
        public WorkerBuilder(IInterface face, IObject owner, IList<IWorker> childWorkers)
        {
            Debug.Assert(face != null, "@face null in WorkerBuilder constructor");
            Debug.Assert(owner != null, "@owner null in WorkerBuilder constructor");
            Debug.Assert(childWorkers != null, "@childWorkers null in WorkerBuilder constructor");

            _face = face;
            _owner = owner;
            _childWorkers = childWorkers;

            _breeders = new Dictionary<IInterface, IFunction>();
            _callees = new Dictionary<IInterface, IFunction>();
            _propGetters = new Dictionary<Identifier, IFunction>();
            _propSetters = new Dictionary<Identifier, IFunction>();
            _methods = new Dictionary<Identifier, IDictionary<IInterface, IFunction>>();
        }
Exemplo n.º 15
0
        public static void CheckOperationsCount(ValidationContext context, IInterface elementToValidate, IList<IOperation> operations)
        {
            //
            if (operations.Count == 0)
            {
                var messageFullString = elementToValidate.Name + " " + ClassNoMethodExceptionMessage;
                context.LogError(messageFullString, ClassNoMethodExceptionNumber, elementToValidate as Microsoft.VisualStudio.Modeling.ModelElement);
                return;
            }

            if (operations.Count > MaxMethodsInClass)
            {
                var messageFullString = elementToValidate.Name + " " + ClassMethodsToMuchExceptionMessage;
                context.LogError(messageFullString, ClassMethodsToMuchExceptionNumber, elementToValidate as Microsoft.VisualStudio.Modeling.ModelElement);
            }
        }
Exemplo n.º 16
0
        private static void WriteInterfaces(StreamWriter streamWriter, IInterface iinterface)
        {
            Debug.WriteLine("		{0}", iinterface.Name);
            streamWriter.WriteLine("		{0}", iinterface.Name);
            Debug.WriteLine("	Required Interfaces:");
            streamWriter.WriteLine("	Required Interfaces:");
            foreach (var ioperation in iinterface.OwnedOperations)
            {
                var returnTypeName = string.Empty;

                var strToWrite = string.Empty;
                foreach (var parameter in ioperation.OwnedParameters)
                {
                    if (parameter.Type == null)
                    {
                        if (parameter.Direction == ParameterDirectionKind.Return)
                        {
                            returnTypeName = "notDefined";
                        }
                        else
                        {
                            strToWrite += string.Format("{0} {1}, ", "notDefined", "notDefined");
                        }
                    }
                    else
                    {
                        if (parameter.Direction == ParameterDirectionKind.Return)
                        {
                            returnTypeName = parameter.Type.Name;
                        }
                        else
                        {
                            strToWrite += string.Format("{0} {1}, ", parameter.Type.Name, parameter.Name);
                        }
                    }
                }
                if (string.IsNullOrEmpty(returnTypeName))
                {
                    returnTypeName = "void";
                }

                strToWrite = strToWrite.TrimEnd(',', ' ');
                strToWrite = string.Format("				{1} {0} (", ioperation.Name, returnTypeName) + strToWrite + ")";
                Debug.WriteLine(strToWrite);
                streamWriter.WriteLine(strToWrite);
            }
        }
Exemplo n.º 17
0
        public void Init()
        {
            l.Debug("Инициирую");

            interf = Core.GetGlobal("Interface") as IInterface;

            if (interf != null)
            {
                interf.AddMenuItem("Логи", "Уровень логирования", "Debug", menuClick);
                interf.AddMenuItem("Логи", "Уровень логирования", "Info", menuClick);
                interf.AddMenuItem("Логи", "Уровень логирования", "Warn", menuClick);
                interf.AddMenuItem("Логи", "Уровень логирования", "Error", menuClick);
                interf.AddMenuItem("Логи", "Уровень логирования", "Fatal", menuClick);
                interf.AddMenuItem("Логи", "Уровень логирования", "NoLog", menuClick);
            }
            else
                l.Error("interf == null");
        }
Exemplo n.º 18
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IInterface interfacesCasted = item.As <IInterface>();

                if ((interfacesCasted != null))
                {
                    this._parent.Interfaces.Add(interfacesCasted);
                }
                FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.SystemIndependent.IComponent componentsCasted = item.As <FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.SystemIndependent.IComponent>();
                if ((componentsCasted != null))
                {
                    this._parent.Components.Add(componentsCasted);
                }
                ISignature availableSignaturesCasted = item.As <ISignature>();

                if ((availableSignaturesCasted != null))
                {
                    this._parent.AvailableSignatures.Add(availableSignaturesCasted);
                }
            }
Exemplo n.º 19
0
        private void Prepare()
        {
            thisInterface = persistentType as IInterface;
            if (thisInterface == null)
            {
                return;
            }

            //inheritanceTree = thisInterface.GetInheritanceTree();
            inheritanceTree = InheritanceTreeCache.Get(thisInterface);
            if (!inheritanceTree.TreeRebuilded)
            {
                inheritanceTree.RebuildTree();
            }
            allInheritanceTypes = inheritanceTree.GetFlatList(InheritanceListMode.WholeTree);

            PrepareTypeAttributes();
            PrepareProperties();
            PreparePropertiesTypeAttributes();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Registers a daemon interface.
        /// </summary>
        /// <returns>The daemon's full id if added to the game, <c>null</c> otherwise.</returns>
        /// <param name="id">The daemon interface id to insert.</param>
        /// <param name="inter">The interface to add.</param>
        public static string RegisterDaemon(string id, IInterface inter)
        {
            if (Pathfinder.CurrentMod == null && !Extension.Handler.CanRegister)
            {
                throw new InvalidOperationException("RegisterDaemon can not be called outside of mod or extension loading.");
            }
            id = Pathfinder.CurrentMod != null?Utility.GetId(id, throwFindingPeriod : true) : Extension.Handler.ActiveInfo.Id + "." + id;

            Logger.Verbose("{0} {1} attempting to add daemon interface {2} with id {3}",
                           Pathfinder.CurrentMod != null ? "Mod" : "Extension",
                           Pathfinder.CurrentMod?.GetCleanId() ?? Extension.Handler.ActiveInfo.Id,
                           inter.GetType().FullName,
                           id);
            if (ModDaemons.ContainsKey(id))
            {
                return(null);
            }
            ModDaemons.Add(id, inter);
            return(id);
        }
Exemplo n.º 21
0
        public static readonly string RequireNameFull = typeof(IRequire <>).FullName.Substring(0, typeof(IRequire <>).FullName.Length); // IRequire'1

        public static bool IsIRequire(IInterface iRequire)
        {
            if (iRequire == null)
            {
                return(false);
            }


            if (iRequire.ShortName != RequireName)
            {
                return(false);
            }

            if (iRequire.GetClrName().FullName != RequireNameFull)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 22
0
        public void MinimalCreateOnResolve()
        {
            IContainer container = new OdysseyContainer(new List <Registration>
            {
                new Registration(typeof(IInterface), typeof(Implementation), createOnResolve: true),
                new Registration(typeof(IInterface), typeof(Implementation2), createOnResolve: true, name: "This"),
            });

            IInterface service1 = (IInterface)container.Resolve(new Resolution(typeof(IInterface), name: "This"));
            IInterface service2 = (IInterface)container.Resolve(new Resolution(typeof(IInterface), name: "This"));
            IInterface service3 = (IInterface)container.Resolve(new Resolution(typeof(IInterface)));

            Assert.IsNotNull(service1);
            Assert.IsNotNull(service2);
            Assert.IsNotNull(service3);

            Assert.IsFalse(ReferenceEquals(service1, service2));
            Assert.IsFalse(ReferenceEquals(service1, service3));
            Assert.IsFalse(ReferenceEquals(service2, service3));
        }
Exemplo n.º 23
0
 public NType(IWorker worker)
 {
     /* xxx
     if candowncast(worker, Bridge.stdn_Type)
     worker = downcast(worker, Bridge.stdn_Type)
     else
     throw
     face = worker.face
     if face == Bridge.stdn_Interface
     ...
     elif face == Bridge.stdn_Nullable
     ...
     elif face == ManualType
     ...
     ...
     */
     //xxx for now, worker must be an interface
     _type = TypeType.INTERFACE;
     _face = Bridge.toNativeInterface(worker);
 }
        public void TypeMappingStrategyAllowsToInterceptNonMBROs()
        {
            Builder    builder    = new Builder();
            PolicyList policyList = CreatePolicyList(GetInjectionSettings(), true);

            policyList.Set <IBuildKeyMappingPolicy>(
                new BuildKeyMappingPolicy(NamedTypeBuildKey.Make <ClassThatImplementsInterface>(string.Empty)),
                NamedTypeBuildKey.Make <IInterface>(string.Empty));

            IInterface instance
                = (IInterface)builder.BuildUp(null,
                                              null,
                                              policyList,
                                              baseStrategyChain.MakeStrategyChain(),
                                              NamedTypeBuildKey.Make <IInterface>(string.Empty),
                                              null);

            Assert.IsNotNull(instance);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(instance));
        }
    public static IDeclaredElement GetPrimaryDeclaredElementForInterface(IInterface @interface)
    {
      string interfaceName = @interface.ShortName;
      var cache = @interface.GetPsiServices().Solution.GetComponent<PsiCache>();
      IEnumerable<PsiOptionSymbol> prefixes = cache.GetOptionSymbols("\"interfaceNamePrefix\"");
      IList<IPsiSymbol> symbols = new List<IPsiSymbol>();
      foreach (PsiOptionSymbol prefix in prefixes)
      {
        string prefixValue = prefix.Value;
        if ((prefixValue.Length < interfaceName.Length) && (prefixValue.Equals(interfaceName.Substring(0, prefixValue.Length))))
        {
          string shortInterfaceName = PsiRenamesFactory.NameFromCamelCase(interfaceName.Substring(prefixValue.Length, interfaceName.Length - prefixValue.Length));
          List<IPsiSymbol> allSymbols = cache.GetSymbols(PsiRenamesFactory.NameFromCamelCase(shortInterfaceName)).ToList();
          foreach (IPsiSymbol symbol in allSymbols)
          {
            if (symbol.SourceFile == prefix.SourceFile)
            {
              symbols.Add(symbol);
            }
          }
        }
      }

      if (symbols.Count == 0)
      {
        return null;
      }

      // TODO: move symbol binding logic to the cache, remove copy-paste.
      IPsiSymbol returnSymbol = Enumerable.ToArray(symbols)[0];
      ITreeNode element = returnSymbol.SourceFile.GetPsiFile<PsiLanguage>(new DocumentRange(returnSymbol.SourceFile.Document, 0)).FindNodeAt(new TreeTextRange(new TreeOffset(returnSymbol.Offset), 1));
      while (element != null)
      {
        var ret = element as IDeclaredElement;
        if (ret != null)
          return ret;

        element = element.Parent;
      }
      return null;
    }
Exemplo n.º 26
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(NMF.Models.IModelElement item)
 {
     if ((this._parent.Repository == null))
     {
         IRepository repositoryCasted = item.As <IRepository>();
         if ((repositoryCasted != null))
         {
             this._parent.Repository = repositoryCasted;
             return;
         }
     }
     if ((this._parent.Type == null))
     {
         IInterface typeCasted = item.As <IInterface>();
         if ((typeCasted != null))
         {
             this._parent.Type = typeCasted;
             return;
         }
     }
 }
Exemplo n.º 27
0
        public void GeneratedProxyImplementsInterceptionBehaviorProvidedAdditionalInterfaces()
        {
            bool invoked = false;
            IInterceptionBehavior interceptionBehavior =
                new DelegateInterceptionBehavior(
                    (mi, next) => { invoked = true; return(mi.CreateMethodReturn(100)); },
                    () => new[] { typeof(ISomeInterface) });

            IInterface proxy = (IInterface)
                               Intercept.ThroughProxyWithAdditionalInterfaces(
                typeof(IInterface),
                new BaseClass(10),
                new InterfaceInterceptor(),
                new[] { interceptionBehavior },
                Type.EmptyTypes);

            int value = ((ISomeInterface)proxy).DoSomethingElse();

            Assert.AreEqual(100, value);
            Assert.IsTrue(invoked);
        }
        public void CanSetUpAdditionalInterfaceThroughInjectionMemberForInstanceInterception()
        {
            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();

            int invokeCount = 0;

            container.RegisterType <IInterface, BaseClass>("test",
                                                           new Interceptor <InterfaceInterceptor>(),
                                                           new AdditionalInterface(typeof(IOtherInterface)),
                                                           new InterceptionBehavior(
                                                               new DelegateInterceptionBehavior(
                                                                   (mi, gn) => { invokeCount++; return(mi.CreateMethodReturn(0)); })));

            IInterface instance = container.Resolve <IInterface>("test");

            ((IOtherInterface)instance).DoSomethingElse("1");

            Assert.AreEqual(1, invokeCount);
        }
Exemplo n.º 29
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IService servicesCasted = item.As <IService>();

                if ((servicesCasted != null))
                {
                    this._parent.Services.Add(servicesCasted);
                }
                IInterface providedInterfacesCasted = item.As <IInterface>();

                if ((providedInterfacesCasted != null))
                {
                    this._parent.ProvidedInterfaces.Add(providedInterfacesCasted);
                }
                IInterface requiredInterfacesCasted = item.As <IInterface>();

                if ((requiredInterfacesCasted != null))
                {
                    this._parent.RequiredInterfaces.Add(requiredInterfacesCasted);
                }
            }
Exemplo n.º 30
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Parameter == null))
     {
         IParameter parameterCasted = item.As <IParameter>();
         if ((parameterCasted != null))
         {
             this._parent.Parameter = parameterCasted;
             return;
         }
     }
     if ((this._parent.Interface_RequiredCharacterisation == null))
     {
         IInterface interface_RequiredCharacterisationCasted = item.As <IInterface>();
         if ((interface_RequiredCharacterisationCasted != null))
         {
             this._parent.Interface_RequiredCharacterisation = interface_RequiredCharacterisationCasted;
             return;
         }
     }
 }
Exemplo n.º 31
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IInterface interfacesCasted = item.As <IInterface>();

                if ((interfacesCasted != null))
                {
                    this._parent.Interfaces.Add(interfacesCasted);
                }
                IComponent_MM06 componentsCasted = item.As <IComponent_MM06>();

                if ((componentsCasted != null))
                {
                    this._parent.Components.Add(componentsCasted);
                }
                ISignature availableSignaturesCasted = item.As <ISignature>();

                if ((availableSignaturesCasted != null))
                {
                    this._parent.AvailableSignatures.Add(availableSignaturesCasted);
                }
            }
Exemplo n.º 32
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Interface == null))
     {
         IInterface interfaceCasted = item.As <IInterface>();
         if ((interfaceCasted != null))
         {
             this._parent.Interface = interfaceCasted;
             return;
         }
     }
     if ((this._parent.ConnectedAssemblyContext == null))
     {
         IAssemblyContext connectedAssemblyContextCasted = item.As <IAssemblyContext>();
         if ((connectedAssemblyContextCasted != null))
         {
             this._parent.ConnectedAssemblyContext = connectedAssemblyContextCasted;
             return;
         }
     }
 }
Exemplo n.º 33
0
    //public Hashtable has;
    //public Dictionary<float, byte> dic;
    //public Queue arrqueue;
    //public Queue<double> queue;
    //public Stack arrsta;
    //public Stack<decimal> sta;

    //public ArrayList[] a;

    public MyClass(MyEnum enu, sbyte sby, byte @by, char ch,
                   short sh, ushort ush, uint uin, long lo, ulong ulo,
                   int num, bool isbo, MyStruct ms, object obj, string str,
                   Class1 c1, IInterface ii, Action ac, int[] arrint, Class1[] arrClass1S,
                   ArrayList arrlist, List <int> list, Hashtable has, Dictionary <float, byte> dic,
                   Queue arrqueue, Queue <double> queue, Stack arrsta, Stack <decimal> sta, List <ArrayList> arrl, ArrayList[] a, ClassFace cf, sbyte Sby, byte face)
    {
        this.enu1 = enu;
        this.sby  = sby;
        this.@by  = @by;
        this.ch   = ch;
        this.sh   = sh;
        this.ush  = ush;
        this.uin  = uin;
        this.lo   = lo;
        this.ulo  = ulo;
        this.num  = num;
        this.isbo = isbo;
        this.ms   = ms;
        this.obj  = obj;
        this.str  = str;
        this.c1   = c1;
        //this.ii = ii;
        //this.ac = ac;
        this.arrint  = arrint;
        ArrClass1s   = arrClass1S;
        this.arrlist = arrlist;
        this.list    = list;
        //this.has = has;
        //this.dic = dic;
        //this.arrqueue = arrqueue;
        //this.queue = queue;
        //this.arrsta = arrsta;
        //this.sta = sta;
        this.arrl = arrl;
        //this.a = a;
        this.cf   = cf;
        this.Sby  = Sby;
        this.face = face;
    }
        internal CommandLineApplication(
            CommandRegistry registry,
            IContainer container,
            IInterface intfc)
        {
            _registry  = registry;
            _resolver  = new CommandResolver(registry);
            _activator = new CommandActivator(container ?? new SystemActivatorContainer());

            _interface = intfc;
            _interface.CancelExecutionEvent += (sender, e) =>
            {
                if (IsRunning)
                {
                    _currentCancellationTokenSource.Cancel();
                    if (e != null)
                    {
                        e.Cancel = true;
                    }
                }
            };
        }
Exemplo n.º 35
0
        static void Main(string[] args)
        {
            MyStruct instance;

            Console.WriteLine(instance.GetHashCode()); //HashCod'ы ОДИНАКОВЫ
            instance.Method();

            //Упаковка Boxing
            IInterface boxed = instance;

            Console.WriteLine(boxed.GetHashCode());   //HashCod'ы ОДИНАКОВЫ
            boxed.Method();

            //Распаковка UnBoxing
            MyStruct unBoxed = (MyStruct)boxed;

            Console.WriteLine(unBoxed.GetHashCode());  //HashCod'ы ОДИНАКОВЫ
            unBoxed.Method();

            //Delay
            Console.ReadKey();
        }
Exemplo n.º 36
0
        /// <summary>
        /// 定时器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                // string typeName = typeof(TM2655P).AssemblyQualifiedName;
                //LISYQ.TM2655P, TM2655P, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
                string errMsg = "";


                if (yqDemo == null)
                {
                    string yqVersion = System.Configuration.ConfigurationSettings.AppSettings["TM2655P"].ToString();
                    yqDemo = LisFactory.LisCreate(yqVersion);
                }

                richTextBox1.Text = richTextBox1.Text + "::" + yqDemo.getDataReceived(out errMsg);
            }
            catch (Exception ex)
            {
                timer1.Enabled = false;
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 37
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IService serviceItem = item.As <IService>();

                if (((serviceItem != null) &&
                     this._parent.Services.Remove(serviceItem)))
                {
                    return(true);
                }
                IInterface interfaceItem = item.As <IInterface>();

                if (((interfaceItem != null) &&
                     this._parent.ProvidedInterfaces.Remove(interfaceItem)))
                {
                    return(true);
                }
                if (((interfaceItem != null) &&
                     this._parent.RequiredInterfaces.Remove(interfaceItem)))
                {
                    return(true);
                }
                return(false);
            }
Exemplo n.º 38
0
        static void Main()
        {
            Console.Title = "CLIENT";

            IInterface proxy = ChannelFactory <IInterface> .CreateChannel(
                new BasicHttpBinding(), new EndpointAddress("http://localhost:7787/IInterface"));

            //   IInterface chanel = chanel.Add()
            //ChannelFactory<IInterface> proxy = new ChannelFactory<IInterface>(new BasicHttpBinding(),
            //    new EndpointAddress("http://localhost:7787/IInterface"));
            //IInterface chanel = proxy.CreateChannel();
            using (proxy as IDisposable)
            {
                int i = proxy.Add(2, 3);
                Console.WriteLine(i);

                //double d = proxy.Add(2.7, 9.3);
                //Console.WriteLine(d);
            }

            // Задержка.
            Console.ReadKey();
        }
Exemplo n.º 39
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                //string typeName = typeof(TM2655P).AssemblyQualifiedName;
                //LISYQ.TM2655P, TM2655P, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
                string errMsg = "";


                if (yqDemo == null)
                {
                    string yqVersion = System.Configuration.ConfigurationSettings.AppSettings["TM2655P"].ToString();
                    yqDemo = LisFactory.LisCreate(yqVersion);
                }

                yqDemo.stop(out errMsg);
                //yqDemo.YQDataReceived("", out errMsg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 40
0
        public virtual void OnReceive(IInterface sender, byte[] data, int dataLength)
        {
            ProtocolFrame rf;

            foreach (byte b in data)
            {
                m_ReceivedDataQueue.Enqueue(b);
            }
            do
            {
                rf = ProtocolFrame.AnalyzeQueue(ref m_ReceivedDataQueue);

                if (rf != null)
                {
                    m_ReceivedTelegrams.Add(rf);
                }
            } while (rf != null);

            if (m_ReceivedTelegrams.Count > 0)
            {
                m_Latch.SignalAll();
            }
        }
Exemplo n.º 41
0
        public void CanSetUpInterceptorThroughInjectionMember()
        {
            CallCountHandler handler = new CallCountHandler();

            IUnityContainer container = new UnityContainer();

            container.AddNewExtension <Interception>();
            container.Configure <Interception>()
            .AddPolicy("policy")
            .AddMatchingRule <AlwaysMatchingRule>()
            .AddCallHandler(handler);

            container.RegisterType <IInterface, BaseClass>(
                "test",
                new Interceptor <InterfaceInterceptor>(),
                new InterceptionBehavior <PolicyInjectionBehavior>());

            IInterface instance = container.Resolve <IInterface>("test");

            instance.DoSomething("1");

            Assert.AreEqual(1, handler.CallCount);
        }
Exemplo n.º 42
0
        private DataTable GetDataTable(string paratime, out string errMsg)
        {
            DataTable dt = null;

            errMsg = "";
            if (yqDemo != null)
            {
                if (yqDemo.IsOpen(out errMsg) == false)
                {
                    yqDemo.open(out errMsg);
                }

                dt = yqDemo.YQDataReturn(paratime, out errMsg);
            }
            else
            {
                if (yqxh.Trim().Length == 0)
                {
                    return(dt);
                }

                if (yqDemo == null)
                {
                    string yqVersion = XmlRW.GetValueFormXML(Common.getyqPath(yqxh), "YQ_Version", "value");
                    yqDemo = LisFactory.LisCreate(yqVersion);
                }

                if (yqDemo.IsOpen(out errMsg) == false)
                {
                    yqDemo.open(out errMsg);
                }

                dt = yqDemo.YQDataReturn(paratime, out errMsg);
            }

            return(dt);
        }
Exemplo n.º 43
0
        //TODO turn this into a chain
        private IVariable MockClassVariable(IMethod method, IInterface theInterface)
        {
            if ((method.ReturnType.IsVoid() || method.ReturnType.IsTask()) && method.Parameters.IsEmpty())
            {
                return(new MockMethodVariable(method, theInterface));
            }

            if ((method.ReturnType.IsVoid() || method.ReturnType.IsTask()) && method.Parameters.Any())
            {
                return(new MockMethodWithParamVariable(method, theInterface));
            }

            if (!(method.ReturnType.IsVoid() || method.ReturnType.IsTask()) && method.Parameters.Any())
            {
                return(new MockMethodWithParamAndResponseVariable(method, theInterface));
            }

            if (!(method.ReturnType.IsVoid() || method.ReturnType.IsTask()) && method.Parameters.IsEmpty())
            {
                return(new MockMethodWithResponseVariable(method, theInterface));
            }

            throw new NotSupportedException("You're not supposed to be here");
        }
Exemplo n.º 44
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IInterface interfaceItem = item.As <IInterface>();

                if (((interfaceItem != null) &&
                     this._parent.Interfaces.Remove(interfaceItem)))
                {
                    return(true);
                }
                FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.SystemIndependent.IComponent componentItem = item.As <FZI.SoftwareEngineering.DeepModeling.TwoLevelADL.SystemIndependent.IComponent>();
                if (((componentItem != null) &&
                     this._parent.Components.Remove(componentItem)))
                {
                    return(true);
                }
                ISignature signatureItem = item.As <ISignature>();

                if (((signatureItem != null) &&
                     this._parent.AvailableSignatures.Remove(signatureItem)))
                {
                    return(true);
                }
                return(false);
            }
Exemplo n.º 45
0
        //TODO turn this into a chain
        private ISignature2 MockAssertMethod(IMethod method, IInterface theInterface)
        {
            if (method.Parameters.IsEmpty())
            {
                return(new MockMethodAsserts(method, theInterface));
            }

            if (method.ReturnType.IsVoid() || method.ReturnType.IsTask())
            {
                return(new MockMethodParamAsserts(method, theInterface));
            }

            if (!(method.ReturnType.IsVoid() || method.ReturnType.IsTask()) && method.Parameters.Any())
            {
                return(new MockMethodWithParamAndResponseAsserts(method, theInterface));
            }

            if (!(method.ReturnType.IsVoid() || method.ReturnType.IsTask()))
            {
                return(new MockMethodResponseAsserts(method, theInterface));
            }

            throw new NotSupportedException("You're not supposed to be here");
        }
        protected Method findMethod(IInterface cls, string methodName, bool isStatic, Expression[] args)
        {
            var allBases = cls is Class class_?class_.getAllBaseInterfaces().filter(x => x is Class) : cls.getAllBaseInterfaces();

            var methods = new List <Method>();

            foreach (var base_ in allBases)
            {
                foreach (var m in base_.methods)
                {
                    var minLen = m.parameters.filter(p => p.initializer == null).length();
                    var maxLen = m.parameters.length();
                    var match  = m.name == methodName && m.isStatic == isStatic && minLen <= args.length() && args.length() <= maxLen;
                    if (match)
                    {
                        methods.push(m);
                    }
                }
            }

            if (methods.length() == 0)
            {
                throw new Error($"Method '{methodName}' was not found on type '{cls.name}' with {args.length()} arguments");
            }
            else if (methods.length() > 1)
            {
                // TODO: actually we should implement proper method shadowing here...
                var thisMethods = methods.filter(x => x.parentInterface == cls);
                if (thisMethods.length() == 1)
                {
                    return(thisMethods.get(0));
                }
                throw new Error($"Multiple methods found with name '{methodName}' and {args.length()} arguments on type '{cls.name}'");
            }
            return(methods.get(0));
        }
Exemplo n.º 47
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="diInterface"></param>
        /// <param name="logger"></param>
        public ValuesController(Context context, IInterface diInterface, ILogger <ValuesController> logger)
        {
            _context = context;
            _logger  = logger;

            if (!_context.Values.Any())
            {
                _context.Values.Add(new ValueItem {
                    Name = diInterface.Method()
                });
                _context.Values.Add(new ValueItem {
                    Name = "Item1"
                });
                _context.Values.Add(new ValueItem {
                    Name = "Item2"
                });
                _context.Values.Add(new ValueItem {
                    Name = "Item3"
                });
                _context.SaveChanges();
            }

            _logger.LogDebug("Controller constructor was called.");
        }
Exemplo n.º 48
0
        public void OnReceive(IInterface sender, byte[] data, int dataLength)
        {
            m_telegram_acknowledged.Set();

            if (dataLength > 5)
            {
                if (data[0] == 0x55 && data[4] == 0x26 && data[5] == 0x01)
                {
                    m_start_indication_received.Set();
                }
                else if (data[0] == 0x55 && data[4] == 0x1E)
                {
                    Console.WriteLine("Version: " + data[5] + "." + data[6] + "." + data[7] + "." + data[8]);
                }
                else if (data[0] == 0x55 && data[4] == 0x2E && data[5] == 0x00)
                {
                    Console.Write(".");
                }
                else
                {
                    Console.WriteLine(WcaInterfaceLibrary.Converter.ByteArray2String(data));
                }
            }
        }
Exemplo n.º 49
0
        public SerialPortOpenStateWatcher(IInterface port)
        {
            _port = port;
            watchLoop();

            async void watchLoop()
            {
                while (true)
                {
                    IsOpen = await CommonUtils.ExecuteSynchronouslyAsync(() => _port.IsOpen, _port.Locker);

                    if (IsOpen)
                    {
                        await CommonUtils.LoopWhileTrueAsync(() => _port.IsOpen, UPDATE_PERIOD, _port.Locker);

                        Closed?.Invoke(this);
                    }
                    else
                    {
                        await CommonUtils.LoopWhileTrueAsync(() => !_port.IsOpen, UPDATE_PERIOD, _port.Locker);
                    }
                }
            }
        }
Exemplo n.º 50
0
 private concrete getConcrete(IInterface z) {
    return new concrete();
 }
 public ClassWithOneInterfaceParameter(IInterface foo)
 {
 }
Exemplo n.º 52
0
 public override void BeginEditParams(IInterface ip, IIUtil iu)
 {
     ip.PushPrompt("Hello Dot Net!");
 }
 public U(IInterface s)
 {
     this.s = s;
 }
Exemplo n.º 54
0
 public override void EndEditParams(IInterface ip, IIUtil iu)
 {
     ip.PopPrompt();
 }
Exemplo n.º 55
0
 /// <summary>
 /// 接口验证
 /// </summary>
 /// <param name="context"></param>
 /// <param name="interfaceModel"></param>
 public void ValidateInterfaceName(ValidationContext context, IInterface interfaceModel)
 {
     if (interfaceModel.OwnedAttributes.Count() > 0)
     {
         context.LogWarning(
              string.Format("Interface {0}中存在属性", interfaceModel.Name),
              "001", interfaceModel);
     }
 }
 public Service(IInterface @interface)
 {
     this.@interface = @interface;
 }
Exemplo n.º 57
0
 public bool ExistSupertype(IInterface @interface)
 {
     this.MetaPopulation.Derive();
     return this.derivedSupertypes.Contains(@interface);
 }
Exemplo n.º 58
0
 public void FreezeFirstParameterByInterfaceShouldAssignSameInstanceToSecondParameter(
     [Frozen(Matching.ImplementedInterfaces)]NoopInterfaceImplementer p1,
     IInterface p2)
 {
     Assert.Equal(p1, p2);
 }
Exemplo n.º 59
0
 public NetworkEntity AddInterface(IInterface iface)
 {
     Contract.Requires <ArgumentNullException> (iface != null);
     Contract.Ensures (Contract.Result <NetworkEntity> () != null);
     Contract.Ensures (Contract.Exists (this.Interfaces, i => i == iface));
     Contract.EnsuresOnThrow <NetworkContainsInterfaceException> (Contract.Exists (this.Interfaces,
                                                                                   i => i == iface));
     return default (NetworkEntity);
 }
 public OuterService(IInterface @interface)
 {
     Interface = @interface;
 }