Ejemplo n.º 1
0
        public TypeManager()
        {
            _predefTypes = null; // Initialized via the Init call.
            _BSymmgr = null; // Initialized via the Init call.
            _typeFactory = new TypeFactory();
            _typeTable = new TypeTable();

            // special types with their own symbol kind.
            _errorType = _typeFactory.CreateError(null, null, null, null, null);
            _voidType = _typeFactory.CreateVoid();
            _nullType = _typeFactory.CreateNull();
            _typeUnit = _typeFactory.CreateUnit();
            _typeAnonMeth = _typeFactory.CreateAnonMethod();
            _typeMethGrp = _typeFactory.CreateMethodGroup();
            _argListType = _typeFactory.CreateArgList();

            InitType(_errorType);
            _errorType.SetErrors(true);

            InitType(_voidType);
            InitType(_nullType);
            InitType(_typeUnit);
            InitType(_typeAnonMeth);
            InitType(_typeMethGrp);

            _stvcMethod = new StdTypeVarColl();
            _stvcClass = new StdTypeVarColl();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor which creates a RunspacePool using the
        /// supplied <paramref name="connectionInfo"/>, <paramref name="minRunspaces"/> 
        /// and <paramref name="maxRunspaces"/>
        /// </summary>
        /// <param name="maxRunspaces">
        /// The maximum number of Runspaces that can exist in this pool. 
        /// Should be greater than or equal to 1.
        /// </param>
        /// <param name="minRunspaces">
        /// The minimum number of Runspaces that can exist in this pool.
        /// Should be greater than or equal to 1.
        /// </param>
        /// <param name="typeTable">
        /// The TypeTable to use while deserializing/serializing remote objects.
        /// TypeTable has the following information used by serializer:
        ///   1. SerializationMethod
        ///   2. SerializationDepth
        ///   3. SpecificSerializationProperties
        /// TypeTable has the following information used by deserializer:
        ///   1. TargetTypeForDeserialization
        ///   2. TypeConverter
        /// </param>
        /// <param name="host">Host associated with this runspacepool</param>
        /// <param name="applicationArguments">
        /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/>
        /// </param>
        /// <param name="connectionInfo">The RunspaceConnectionInfo object
        /// which identifies this runspace pools connection to the server
        /// </param>
        /// <param name="name">Session name.</param>
        /// <exception cref="ArgumentException">
        /// Maximum runspaces is less than 1.
        /// Minimum runspaces is less than 1.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// ConnectionInfo specified is null
        /// </exception>
        internal RemoteRunspacePoolInternal(int minRunspaces,
            int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null)
            : base(minRunspaces, maxRunspaces)
        {
            if (connectionInfo == null)
            {
                throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo");
            }

            PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor,
                    PSOpcode.Constructor, PSTask.CreateRunspace,
                    PSKeyword.UseAlwaysOperational,
                    instanceId.ToString(),
                    minPoolSz.ToString(CultureInfo.InvariantCulture),
                    maxPoolSz.ToString(CultureInfo.InvariantCulture));

            _connectionInfo = connectionInfo.InternalCopy();

            this.host = host;
            ApplicationArguments = applicationArguments;
            AvailableForConnection = false;
            DispatchTable = new DispatchTable<object>();
            _runningPowerShells = new System.Collections.Concurrent.ConcurrentStack<PowerShell>();

            if (!string.IsNullOrEmpty(name))
            {
                this.Name = name;
            }

            CreateDSHandler(typeTable);
        }
Ejemplo n.º 3
0
        public void Should_Add_Selector_To_Back_Of_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (FullNameSelector) to the back of the processing queue
            table.AddSelector(stringSelector2, SelectorPosition.Last);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            var lastselector = table.GetSelectors<string>().Last();
            Assert.IsInstanceOf<FullNameSelector>(lastselector);
        }
        /// <summary>
        /// Initializes the object with default values.
        /// </summary>
        public NodeCache(Session session)
        {
            if (session == null) throw new ArgumentNullException("session");

            m_session  = session;
            m_typeTree = new TypeTable(m_session.NamespaceUris);
            m_nodes    = new NodeTable(m_session.NamespaceUris, m_session.ServerUris, m_typeTree);
        }
Ejemplo n.º 5
0
        public static TypeKey GetTypeKey(Type type)
        {
            var table = new TypeTable(type);

            var key = table.First(col => col.IsPrimaryKey);
           
            return (key != null ) ? new TypeKey(key.Name, key.Type)
                : null;
        }
	    public void Insert(string TypeName,byte[] Ts)
	    {
		    TypeTable item = new TypeTable();
		    
            item.TypeName = TypeName;
            
            item.Ts = Ts;
            
	    
		    item.Save(UserName);
	    }
		/// <summary>
		/// Creates the <see cref="Table"/> from the descriptor.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="type">The <see cref="ITypeDefinition"/>.</param>
		/// <returns>Returns the created <see cref="Table"/>.</returns>
		protected virtual Table DoCreate(IMansionContext context, ITypeDefinition type)
		{
			// get the name of the table
			var tableName = Properties.Get<string>(context, "tableName");

			// create the type table
			var table = new TypeTable(tableName);

			// return the created table
			return table;
		}
Ejemplo n.º 8
0
 //public static Arbitrary<ITypeSelector[]> Selectors()
 //{
 //    return Gen.Sequence(Gen.Elements(AvailableSelectors)).ToArbitrary();
 //}
 public static Arbitrary<TypeTable> TypeTable()
 {
     Func<TypeTable> generator = () =>
     {
         var table = new TypeTable(Faker.Generators.Booleans.Bool());
         var selectors = AvailableSelectors.GetRandomSelection(Generators.Numbers.Int(0, 10));
         foreach(var selector in selectors)
             table.AddSelector(selector);
         return table;
     };
     return Arb.From(Gen.Fresh(generator));
 }
Ejemplo n.º 9
0
        public void Should_Add_Type_Selectors_For_Multiple_Types_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some string selectors that we're going to add
            var stringSelector1 = new StringSelector();

            //Create some long selectors that we're going to use...
            var longSelector1 = new LongSelector();
            var longSelector2 = new TimeStampSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet");

            //Add the first and only string selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(0, table.CountSelectors<long>(), "should have ZERO type selectors for type 'long' since we haven't added any yet"); //Assert that we haven't added any long selectors yet

            var firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            var currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsNull(currentLongSelector); //Since we haven't added any long selectors yet, this should return null

            //Add the first long selector (our default long selector)
            table.AddSelector<long>(longSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(1, table.CountSelectors<long>(), "should have ONE type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<LongSelector>(currentLongSelector);

            //Add the final long selector (our timestamp selector)
            table.AddSelector<long>(longSelector2);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");
            Assert.AreEqual(2, table.CountSelectors<long>(), "should have TWO type selectors for type 'long'");

            firstStringSelector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstStringSelector);

            currentLongSelector = table.GetSelectors<long>().FirstOrDefault();
            Assert.IsInstanceOf<TimeStampSelector>(currentLongSelector);
        }
Ejemplo n.º 10
0
        public void GetTByExpression()
        {

            Expression<Func<Customer, bool>> expression = e => e.ID == 1;

            var customer = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(true);

            var provider = new IProvider();

            var command = new ICommand();

            var schema = new TypeTable(typeof(Customer));

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);

            provider.CommandBuilder.Setup(c => c.CreateGetTCommand<Customer>(expression)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteReader(command.Object)).Returns(reader.Object);

            provider.Mapper.Setup(m => m.GetTMappingMethod<Customer>()).Returns(d => customer);

            var target = new DataSession(provider.Object);

            var actual = target.GetT(expression);

            Assert.AreEqual(actual, customer);
        }
Ejemplo n.º 11
0
        public void GetPagedListByExpression()
        {
            Expression<Func<Customer, bool>> expression = e => e.ID < 4;

            var customer1 = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };
            var customer2 = new Customer
            {
                ID = 2,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 2,
                Name = "Customer2",
                ProfileID = 2
            };
            var customer3 = new Customer
            {
                ID = 3,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 3,
                Name = "Customer3",
                ProfileID = 3
            };

            var customerQueue = new Queue<Customer>(new[] { customer1, customer2, customer3 });
            var readerResults = new Queue<bool>(new[] { true, true, true, false });

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(readerResults.Dequeue);

            var provider = new IProvider();

            var command = new ICommand();

            var schema = new TypeTable(typeof(Customer));

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);

            provider.CommandBuilder.Setup(c => c.CreateGetListByPageCommand<Customer>(expression)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteReader(command.Object)).Returns(reader.Object);

            provider.Mapper.Setup(m => m.GetTMappingMethod<Customer>()).Returns(d => customerQueue.Dequeue());

            var target = new DataSession(provider.Object);

            var actual = target.GetPagedList<List<Customer>, Customer>(10, 1, expression);

            Assert.IsTrue(actual[0].ID == 1 &&
                actual[1].ID == 2 && actual[2].ID == 3);

        }
Ejemplo n.º 12
0
        public void GetTByProcedure()
        {
            var procedure = new Mock<Procedure>("TestProcedure");

            var customer = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(true);

            var provider = new IProvider();

            var command = new ICommand();

            var schema = new TypeTable(typeof(Customer));

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);

            provider.CommandBuilder.Setup(c => c.CreateCommandFromProcedure(procedure.Object)).Returns(command.Object);

            provider.CommandExecutor.Setup(c => c.ExecuteReader(command.Object)).Returns(reader.Object);

            provider.Mapper.Setup(m => m.GetTMappingMethod<Customer>()).Returns(d => customer);

            var target = new DataSession(provider.Object);

            var actual = target.GetT<Customer>(procedure.Object);

            Assert.AreEqual(actual, customer);

        }
Ejemplo n.º 13
0
        public void SaveUpdate()
        {
            var customer = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };

            var provider = new IProvider();
            var transaction = new Mock<ITransaction>();
            var command = new ICommand();
            var schema = new TypeTable(typeof(Customer));

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(true);


            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandExecutor.Setup(c => c.InitiateTransaction()).Returns(transaction.Object);
            provider.Setup(p => p.GetEntityStatus(customer)).Returns(EntityStatus.Update);
            provider.CommandBuilder.Setup(c => c.CreateUpdateCommand(customer)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteReader(command.Object, transaction.Object)).Returns(
                reader.Object);

            provider.Mapper.Setup(m => m.GetObjectMappingMethod(typeof(Customer))).Returns(d => customer);

            var target = new DataSession(provider.Object);
            target.Save(customer);

            provider.CommandExecutor.Verify(c => c.InitiateTransaction());
            provider.CommandExecutor.Verify(c => c.CommitTransaction(transaction.Object));

            Assert.IsTrue(customer.ID == 1);
        }
Ejemplo n.º 14
0
        public void CountUsingLambda()
        {
            var provider = new IProvider();
            var command = new ICommand();
            var schema = new TypeTable(typeof(Customer));

            Expression<Func<Customer, bool>> expression = x => x.ID < 10;

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandBuilder.Setup(c => c.CreateCountCommand<Customer>(expression.Body)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteCount(command.Object)).Returns(10);

            var target = new DataSession(provider.Object);
            var result = target.Count(expression);
            Assert.IsTrue(result == 10);
        }
Ejemplo n.º 15
0
        internal static IEnumerable <PSObject> Invoke(Guid cmdletUniqueId, string pswsServiceUri, string cmdletCommand, NetworkCredential credential, NameValueCollection headersTobeAdd, TypeTable typeTable)
        {
            CommandInvocation.CheckArgumentNull("pswsServiceUri", pswsServiceUri);
            CommandInvocation.CheckArgumentNull("cmdletCommand", cmdletCommand);
            CommandInvocation.CheckArgumentNull("credential", credential);
            int             tickCount = Environment.TickCount;
            string          value;
            string          value2;
            ResponseContent responseContent = CommandInvocation.CreateRequest(pswsServiceUri, cmdletCommand, credential, headersTobeAdd, out value, out value2);

            while (responseContent.Status == ExecutionStatus.Executing)
            {
                int num = Environment.TickCount - tickCount;
                if (num > 600000)
                {
                    throw new PswsProxyException(Strings.PswsInvocationTimout(600000));
                }
                Thread.Sleep(1000);
                responseContent = CommandInvocation.ResumeRequest(pswsServiceUri, responseContent.Id, credential, headersTobeAdd, out value2);
            }
            CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "TicksElapsed", (Environment.TickCount - tickCount).ToString());
            if (responseContent.Status == ExecutionStatus.Error)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RequestXml", value);
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ResponseXml", value2);
                StringBuilder stringBuilder = new StringBuilder();
                if (headersTobeAdd != null)
                {
                    foreach (string text in headersTobeAdd.AllKeys)
                    {
                        stringBuilder.Append(text);
                        stringBuilder.Append(':');
                        stringBuilder.Append(headersTobeAdd[text]);
                        stringBuilder.Append(' ');
                    }
                }
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RequestHeaders", stringBuilder.ToString());
                throw new PswsProxyCmdletException(responseContent.Error.Exception);
            }
            return(ObjectTransfer.GetResultObjects(responseContent.OutputXml, typeTable));
        }
Ejemplo n.º 16
0
        protected NameAndParameterListView(SerializedProperty property, Action applyAction, string expectedControlLayout, TypeTable listOptions, Func <Type, Type> getValueType, string itemName)
        {
            m_ItemName     = itemName;
            m_GetValueType = getValueType;
            m_DeleteButton = EditorGUIUtility.TrIconContent("Toolbar Minus", $"Delete {itemName}");
            m_UpButton     = EditorGUIUtility.TrIconContent(GUIHelpers.LoadIcon("ChevronUp"), $"Move {itemName} up");
            m_DownButton   = EditorGUIUtility.TrIconContent(GUIHelpers.LoadIcon("ChevronDown"), $"Move {itemName} down");

            m_Property    = property;
            m_Apply       = applyAction;
            m_ListOptions = listOptions;

            m_ExpectedControlLayout = expectedControlLayout;
            if (!string.IsNullOrEmpty(m_ExpectedControlLayout))
            {
                m_ExpectedValueType = EditorInputControlLayoutCache.GetValueType(m_ExpectedControlLayout);
            }

            m_ParametersForEachListItem         = NameAndParameters.ParseMultiple(m_Property.stringValue).ToArray();
            m_EditableParametersForEachListItem = new ParameterListView[m_ParametersForEachListItem.Length];

            for (var i = 0; i < m_ParametersForEachListItem.Length; i++)
            {
                m_EditableParametersForEachListItem[i] = new ParameterListView {
                    onChange = OnParametersChanged
                };
                var typeName = m_ParametersForEachListItem[i].name;
                var rowType  = m_ListOptions.LookupTypeRegistration(typeName);
                m_EditableParametersForEachListItem[i].Initialize(rowType, m_ParametersForEachListItem[i].parameters);

                var name = ObjectNames.NicifyVariableName(typeName);

                ////REVIEW: finding this kind of stuff should probably have better support globally on the asset; e.g. some
                ////        notification that pops up and allows fixing all occurrences in one click
                // Find out if we still support this option and indicate it in the list, if we don't.
                if (rowType == null)
                {
                    name += " (Obsolete)";
                }
                else if (m_ExpectedValueType != null)
                {
                    var valueType = getValueType(rowType);
                    if (!m_ExpectedValueType.IsAssignableFrom(valueType))
                    {
                        name += " (Ignored)";
                    }
                }
                m_EditableParametersForEachListItem[i].name = name;
            }
        }
 internal ClientRunspacePoolDataStructureHandler(RemoteRunspacePoolInternal clientRunspacePool, TypeTable typeTable)
 {
     this.clientRunspacePoolId = clientRunspacePool.InstanceId;
     this.minRunspaces         = clientRunspacePool.GetMinRunspaces();
     this.maxRunspaces         = clientRunspacePool.GetMaxRunspaces();
     this.host = clientRunspacePool.Host;
     this.applicationArguments        = clientRunspacePool.ApplicationArguments;
     this.remoteSession               = this.CreateClientRemoteSession(clientRunspacePool);
     this.transportManager            = this.remoteSession.SessionDataStructureHandler.TransportManager;
     this.transportManager.TypeTable  = typeTable;
     this.remoteSession.StateChanged += new EventHandler <RemoteSessionStateEventArgs>(this.HandleClientRemoteSessionStateChanged);
     this._reconnecting               = false;
     this.transportManager.RobustConnectionNotification += new EventHandler <ConnectionStatusEventArgs>(this.HandleRobustConnectionNotification);
     this.transportManager.CreateCompleted += new EventHandler <CreateCompleteEventArgs>(this.HandleSessionCreateCompleted);
 }
Ejemplo n.º 18
0
 TypeTable CreateArithmeticResultTable()
 // If we have two arguments, what type do we get if we, e.g., add them?
     {
     TypeTable table = new TypeTable(VoidType);
     //
     table[IntegerType, IntegerType] = IntegerType;
     table[FloatType,   IntegerType] = FloatType;
     table[IntegerType, FloatType]   = FloatType;
     table[FloatType,   FloatType]   = FloatType;
     //
     return table;
     }
Ejemplo n.º 19
0
 TypeTable CreatePromotionTable()
 // Construct and return the table that describes the legal automatic type promotions.
 // For example: a strand is a degenerate plex, a plex is a degenerate mixture, etc.
     {
     TypeTable table = new TypeTable();
     //
     table[StrandType, PlexType]    = PlexType;
     table[StrandType, MixtureType] = MixtureType;
     table[PlexType,   MixtureType] = MixtureType;
     //
     table[IntegerType, FloatType] = FloatType;
     //
     table[IntegerType, BoolType]  = BoolType;
     table[FloatType,   BoolType]  = BoolType;
     //
     // We have some syntatic sugar for literal nucleotide strings.
     // 
     table[StringType,  DomainType] = DomainType;
     // table[StringType,  StrandType] = StrandType;     // We don't do this, as it's simple enought to wrap in a [>
     //
     return table;
     }
        /*----< define how each message will be processed >------------*/

        void initializeDispatcher()
        {
            Func <CommMessage, CommMessage> getTopFiles = (CommMessage msg) =>
            {
                localFileMgr.currentPath = "";
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "getTopFiles";
                reply.arguments = localFileMgr.getFiles().ToList <string>();
                return(reply);
            };

            messageDispatcher["getTopFiles"] = getTopFiles;

            Func <CommMessage, CommMessage> getTopDirs = (CommMessage msg) =>
            {
                if (localFileMgr.pathStack.Count != 1)
                {
                    localFileMgr.pathStack.Clear();
                }

                Console.WriteLine(localFileMgr.currentPath);
                localFileMgr.currentPath = "";
                localFileMgr.pathStack.Push(localFileMgr.currentPath);
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "getTopDirs";
                reply.arguments = localFileMgr.getDirs().ToList <string>();
                return(reply);
            };

            messageDispatcher["getTopDirs"] = getTopDirs;

            Func <CommMessage, CommMessage> moveIntoFolderFiles = (CommMessage msg) =>
            {
                if (msg.arguments.Count() == 1)
                {
                    localFileMgr.currentPath = msg.arguments[0];
                }
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "moveIntoFolderFiles";
                reply.arguments = localFileMgr.getFiles().ToList <string>();
                return(reply);
            };

            messageDispatcher["moveIntoFolderFiles"] = moveIntoFolderFiles;

            Func <CommMessage, CommMessage> moveIntoFolderDirs = (CommMessage msg) =>
            {
                if (msg.arguments.Count() == 1)
                {
                    localFileMgr.currentPath = msg.arguments[0];
                }
                localFileMgr.pathStack.Push(localFileMgr.currentPath);
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "moveIntoFolderDirs";
                reply.arguments = localFileMgr.getDirs().ToList <string>();
                return(reply);
            };

            messageDispatcher["moveIntoFolderDirs"] = moveIntoFolderDirs;

            Func <CommMessage, CommMessage> moveUpDirs = (CommMessage msg) =>
            {
                if (localFileMgr.pathStack.Count != 1)
                {
                    localFileMgr.pathStack.Pop();
                    localFileMgr.currentPath = localFileMgr.pathStack.Peek();
                }
                else
                {
                    localFileMgr.pathStack.Pop();
                    localFileMgr.currentPath = Environment.root;
                    localFileMgr.pathStack.Push(localFileMgr.currentPath);
                    localFileMgr.currentPath = localFileMgr.pathStack.Peek();
                }
                Console.WriteLine(localFileMgr.currentPath);
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "moveUpDirs";
                reply.arguments = localFileMgr.getDirs().ToList <string>();
                //Console.WriteLine(localFileMgr.pathStack.Count);
                return(reply);
            };

            messageDispatcher["moveUpDirs"] = moveUpDirs;

            Func <CommMessage, CommMessage> moveUpDirsFile = (CommMessage msg) =>
            {
                if (localFileMgr.pathStack.Count != 0)
                {
                    localFileMgr.currentPath = localFileMgr.pathStack.Peek();
                }
                else
                {
                    localFileMgr.currentPath = Environment.root;
                }
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "moveUpDirsFile";
                reply.arguments = localFileMgr.getFiles().ToList <string>();
                Console.WriteLine(localFileMgr.pathStack.Count);
                return(reply);
            };

            messageDispatcher["moveUpDirsFile"] = moveUpDirsFile;

            Func <CommMessage, CommMessage> moveSelectedFiles = (CommMessage msg) =>
            {
                int temp = 0;
                foreach (var item in selected)
                {
                    if (item == msg.arguments[0])
                    {
                        temp = 1;
                    }
                }
                if (temp == 0 && Path.GetExtension(msg.arguments[0]) == ".cs")
                {
                    selected.Add(msg.arguments[0]);
                }

                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "moveSelectedFiles";
                foreach (var i in selected)
                {
                    reply.arguments.Add(i);
                }
                return(reply);
            };

            messageDispatcher["moveSelectedFiles"] = moveSelectedFiles;

            Func <CommMessage, CommMessage> Add_all = (CommMessage msg) =>
            {
                foreach (var item in msg.arguments)
                {
                    int temp = 0;
                    foreach (var elem in selected)
                    {
                        if (elem == item)
                        {
                            temp = 1;
                        }
                    }
                    if (temp == 0 && Path.GetExtension(item) == ".cs")
                    {
                        selected.Add(item);
                    }
                }

                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "Add_all";
                foreach (var i in selected)
                {
                    reply.arguments.Add(i);
                }
                // reply.arguments = selected;
                return(reply);
            };

            messageDispatcher["Add_all"] = Add_all;

            Func <CommMessage, CommMessage> removeSelectedFiles = (CommMessage msg) =>
            {
                for (var i = 0; i < selected.Count; i++)
                {
                    Console.WriteLine(selected[i]);
                    if (selected[i] == msg.arguments[0])
                    {
                        selected.Remove(selected[i]);
                    }
                }
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "removeSelectedFiles";
                foreach (var i in selected)
                {
                    reply.arguments.Add(i);
                }
                // reply.arguments = selected;
                return(reply);
            };

            messageDispatcher["removeSelectedFiles"] = removeSelectedFiles;

            Func <CommMessage, CommMessage> clearSelectedFiles = (CommMessage msg) =>
            {
                selected.Clear();
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "clearSelectedFiles";

                reply.arguments = selected;
                return(reply);
            };

            messageDispatcher["clearSelectedFiles"] = clearSelectedFiles;

            Func <CommMessage, CommMessage> Generate_TT = (CommMessage msg) => {
                List <string> file_list = new List <string>();
                string        ttt       = Path.GetFullPath(ServerEnvironment.root);
                for (var i = 0; i < msg.arguments.Count; i++)
                {
                    file_list.Add(ttt + msg.arguments[i]);
                }
                TypeTable tt = new TypeTable();
                tt = tt.GetTable(file_list.ToArray());
                for (var i = 0; i < file_list.Count; i++)
                {
                    string temp = Path.GetFileNameWithoutExtension(file_list[i]);

                    file_list[i] = temp;
                    Console.WriteLine(file_list[i]);
                }
                //List<string> type_table = tt.print();
                string      type_table = tt.tt_to_string();
                CommMessage reply      = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "Generate_TT";

                List <string> tt_t = new List <string>();
                tt_t.Add("");
                if (type_table.Length > 1024)
                {
                    string pp = "";
                    for (int i = 0; i < type_table.Length; i++)
                    {
                        pp += type_table[i];
                        if (pp.Length >= 1024)
                        {
                            reply.arguments.Add(pp);
                            pp = "";
                        }
                    }
                    reply.arguments.Add(pp);
                    pp = "";
                }
                else
                {
                    reply.arguments.Add(type_table);
                }
                return(reply);
            };

            messageDispatcher["Generate_TT"] = Generate_TT;

            Func <CommMessage, CommMessage> Generate_DT = (CommMessage msg) => {
                List <string> file_list = new List <string>();
                string        ttt       = Path.GetFullPath(ServerEnvironment.root);
                for (var i = 0; i < msg.arguments.Count; i++)
                {
                    file_list.Add(ttt + msg.arguments[i]);
                }
                DepenAnalysis dp = new DepenAnalysis();
                dp = dp.DepenAnalysises(file_list.ToArray());
                for (var i = 0; i < file_list.Count; i++)
                {
                    string temp = Path.GetFileNameWithoutExtension(file_list[i]);

                    file_list[i] = temp;
                    Console.WriteLine(file_list[i]);
                }

                //List<string> dep_table = dp.asign_table();
                string      dep_table = dp.dep_tostring();
                CommMessage reply     = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "Generate_DT";
                if (dep_table.Length > 1024)
                {
                    string pp = "";
                    for (int i = 0; i < dep_table.Length; i++)
                    {
                        pp += dep_table[i];
                        if (pp.Length >= 1024)
                        {
                            reply.arguments.Add(pp);
                            pp = "";
                        }
                    }
                    reply.arguments.Add(pp);
                    pp = "";
                }
                else
                {
                    reply.arguments.Add(dep_table);
                }
                return(reply);
            };

            messageDispatcher["Generate_DT"] = Generate_DT;

            Func <CommMessage, CommMessage> Generate_SC = (CommMessage msg) =>
            {
                List <string> file_list = new List <string>();
                string        ttt       = Path.GetFullPath(ServerEnvironment.root);
                for (var i = 0; i < msg.arguments.Count; i++)
                {
                    file_list.Add(ttt + msg.arguments[i]);
                }

                CsGraph <string, string> csGraph = new CsGraph <string, string>("Dep_Table");
                csGraph = csGraph.Creat_Graph(file_list.ToArray());
                csGraph.sc_finder();
                for (var i = 0; i < file_list.Count; i++)
                {
                    string temp = Path.GetFileNameWithoutExtension(file_list[i]);

                    file_list[i] = temp;
                    Console.WriteLine(file_list[i]);
                }
                string      SC    = csGraph.SC_tostring();
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "Generate_SC";
                if (SC.Length > 1024)
                {
                    string pp = "";
                    for (int i = 0; i < SC.Length; i++)
                    {
                        pp += SC[i];
                        if (pp.Length >= 1024)
                        {
                            reply.arguments.Add(pp);
                            pp = "";
                        }
                    }
                    reply.arguments.Add(pp);
                    pp = "";
                }
                else
                {
                    reply.arguments.Add(SC);
                }
                return(reply);
            };

            messageDispatcher["Generate_SC"] = Generate_SC;

            Func <CommMessage, CommMessage> importone = (CommMessage msg) => {
                string        path      = Path.GetFullPath(ServerEnvironment.root);
                List <string> dirs_list = new List <string>();
                string        ttt       = Path.GetFullPath(ServerEnvironment.root) + msg.arguments[0];
                Console.WriteLine(msg.arguments[0] + "debuggogogo");
                string        judge     = msg.arguments[0] + "debuggogogo";
                List <string> file_list = new List <string>();
                file_list.AddRange(Directory.GetFiles(ttt).ToList <string>());
                dirs_list.AddRange(Directory.GetDirectories(ttt).ToList <string>());
                int temp1 = path.Length;
                foreach (var i in dirs_list)
                {
                    file_list.AddRange(Directory.GetFiles(i).ToList <string>());
                }
                for (var i = 0; i < file_list.Count; i++)
                {
                    if (judge == "debuggogogo")
                    {
                        file_list[i] = file_list[i].Remove(temp1);
                        Console.WriteLine(file_list[i]);
                        file_list[i] = Path.GetFileName(file_list[i]);
                    }
                    else
                    {
                        file_list[i] = file_list[i].Remove(0, temp1);
                    }
                }
                if (msg.arguments.Count == 0)
                {
                    selected = selected;
                }
                else
                {
                    foreach (var item in file_list)
                    {
                        int temp = 0;
                        foreach (var elem in selected)
                        {
                            if (elem == item)
                            {
                                temp = 1;
                            }
                        }
                        if (temp == 0 && Path.GetExtension(item) == ".cs")
                        {
                            selected.Add(item);
                        }
                    }
                }
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = msg.from;
                reply.from    = msg.to;
                reply.command = "importone";
                foreach (var i in selected)
                {
                    reply.arguments.Add(i);
                }
                return(reply);
            };

            messageDispatcher["importone"] = importone;

            Func <CommMessage, CommMessage> importall = (CommMessage msg) =>
            {
                localFileMgr.all_files.Clear();
                if (localFileMgr.pathStack.Count == 1)
                {
                    localFileMgr.currentPath = ServerEnvironment.root;
                }
                else
                {
                    localFileMgr.currentPath = ServerEnvironment.root + localFileMgr.pathStack.Peek();
                }
                Console.WriteLine(localFileMgr.currentPath);

                string temp  = Path.GetFullPath(ServerEnvironment.root);
                int    temp2 = temp.Length;


                string        dirPath   = Path.GetFullPath(localFileMgr.currentPath);
                List <string> file_sets = new List <string>();



                localFileMgr.FindFile(dirPath);
                file_sets = localFileMgr.all_files;
                for (var i = 0; i < file_sets.Count; i++)
                {
                    file_sets[i] = file_sets[i].Remove(0, temp2);
                }
                selected = file_sets;



                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = msg.from;
                reply.from      = msg.to;
                reply.command   = "importall";
                reply.arguments = file_sets;
                return(reply);
            };

            messageDispatcher["importall"] = importall;
        }
Ejemplo n.º 21
0
 public virtual Classifier CommonSuperType(Classifier other)
 {
     return(TypeTable.CommonSuperType(this, other));
 }
Ejemplo n.º 22
0
        /* public override int GetHashCode() {
         *   return QualifiedName.GetHashCode();
         * }
         *
         * public override bool Equals(object obj) {
         *   if (obj is Classifier != true) {
         *       return false;
         *   }
         *   return QualifiedName == ((Classifier)obj).QualifiedName;
         * }*/

        public virtual bool ConformsTo(Classifier other)
        {
            return(TypeTable.ConformsTo(this, other));
        }
Ejemplo n.º 23
0
 public void OnEnable()
 {
     loadTarget();
     group     = target as GroupControl;
     typeTable = TypeTable.getTable();
 }
Ejemplo n.º 24
0
        public void CountAll()
        {
            var provider = new IProvider();
            var command = new ICommand();
            var schema = new TypeTable(typeof(Customer));

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandBuilder.Setup(c => c.CreateCountCommand<Customer>()).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteCount(command.Object)).Returns(10);

            var target = new DataSession(provider.Object);
            var result = target.Count<Customer>();
            Assert.IsTrue(result == 10);
        }
Ejemplo n.º 25
0
        public void GenerateCode(ClassNode node, ICIL_CodeGenerator codeGenerator = null)
        {
            TypeTable.IsDefinedType(node.TypeClass, out var type);

            //Define init_function
            var initFunction = CIL_Factory.DefineFunction($"{node.TypeClass}_Init");

            // Define Variable ('instance')
            var instance = type.Self.Holder ??
                           (type.Self.Holder = initFunction.CodeGenerator.DefineVariable());

            if (node.TypeClass == "Main")
            {
                // Add Local Variable
                initFunction.CodeGenerator.AddLocalVariable(
                    new CIL_LocalVariable((Variable)instance));

                // Allocate Main
                initFunction.CodeGenerator.AddInstruction(
                    new Allocate((Variable)instance, node.TypeClass));
            }
            else
            {
                // Define argument
                //var argument = initFunction.CodeGenerator.DefineVariable();

                //add Local Variable
                initFunction.CodeGenerator.AddLocalVariable(
                    new CIL_LocalVariable((Variable)instance));

                initFunction.CodeGenerator.AddArgument(
                    new CIL_Argument((Variable)instance));
            }

            if (node.TypeParent != $"{BuiltIn.Object}" &&
                node.TypeParent != $"{BuiltIn.IO}")

            {
                // Set Param to invoke the Parent Init_function
                initFunction.CodeGenerator.AddInstruction(
                    new Param((Variable)instance));

                //Define the variable to hold the result call of the Parent's init_fuction of TypeClass
                var rVcall = initFunction.CodeGenerator.DefineVariable();

                // add Local Variable
                initFunction.CodeGenerator.AddLocalVariable(
                    new CIL_LocalVariable(rVcall));

                //Call the Parent's init_function
                initFunction.CodeGenerator.AddInstruction(
                    new Call(rVcall, $"{node.TypeParent}_Init"));
            }

            foreach (var feature in node.FeatureList.Features)
            {
                switch (feature)
                {
                case LocalOrFieldInit localOrFieldInit:

                    GenerateCode(localOrFieldInit, initFunction.CodeGenerator);

                    initFunction.CodeGenerator.AddInstruction(
                        new SetAttr((Variable)instance, $"{node.TypeClass}_{localOrFieldInit.Name}",
                                    localOrFieldInit.Symbol.Holder));

                    break;

                case MethodNode methodNode:

                    var function = CIL_Factory.DefineFunction($"{node.TypeClass}_{methodNode.FuncName}");

                    function.CodeGenerator
                    .AddLocalVariable(new CIL_LocalVariable((Variable)instance));

                    function.CodeGenerator.AddArgument(
                        new CIL_Argument((Variable)instance));

                    GenerateCode(methodNode, function.CodeGenerator);
                    CIL_Factory.AddFunction(function);

                    break;
                }
            }

            if (node.TypeClass == "Main")
            {
                var result = initFunction.CodeGenerator.DefineVariable();

                // add Local Variable
                initFunction.CodeGenerator.AddLocalVariable(
                    new CIL_LocalVariable(result));

                // set Param to invoke the main function
                initFunction.CodeGenerator.AddInstruction(
                    new Param((Variable)instance));

                //Control is transferred to Main_main
                initFunction.CodeGenerator.AddInstruction(
                    new Call(result, $"{node.TypeClass}_main"));
            }

            //Add the return instruction's
            initFunction.CodeGenerator.AddInstruction(
                new CIL_Return());

            //Add InitFunction with the initialized code
            CIL_Factory.AddFunction(initFunction);
        }
Ejemplo n.º 26
0
 TypeTable CreateEqualityRequiredArgTypeTable()
 // If we have two arguments, what type do we need each to be in order to, e.g., == them?
     {
     TypeTable table = new TypeTable(VoidType);
     //
     table[IntegerType,  IntegerType] = IntegerType;
     table[IntegerType,  FloatType]   = FloatType;
     table[IntegerType,  BoolType]    = BoolType;
     //
     table[FloatType,    IntegerType] = FloatType;
     table[FloatType,    FloatType]   = FloatType;
     table[IntegerType,  BoolType]    = BoolType;
     //
     table[BoolType,     IntegerType] = BoolType;
     table[BoolType,     FloatType]   = FloatType;
     table[BoolType,     BoolType]    = BoolType;
     //
     table[stringType,   StringType]  = StringType;
     //
     return table;
     }
Ejemplo n.º 27
0
 private PhpValue(long value) : this()
 {
     _type       = TypeTable.LongTable;
     _value.Long = value;
 }
Ejemplo n.º 28
0
        public void TypeTable_Contains_ArgumentChecking()
        {
            var tt = new TypeTable();

            Assert.ThrowsException <ArgumentNullException>(() => tt.Contains(default));
Ejemplo n.º 29
0
        public void TypeTableConstructorTest()
        {
            TypeTable target = new TypeTable();

            Assert.Inconclusive("TODO: 实现用来验证目标的代码");
        }
Ejemplo n.º 30
0
 public void Init(InstDeclController graph)
 {
     _symbolTable = GlobalSymbolTable.GetInstance();
     _typeTable   = TypeTable.GetInstance();
     _graph       = graph;
 }
Ejemplo n.º 31
0
        //Finds all the different types and names used in different files



        static TypeTable makett(string[] args)
        {
            TypeTable tt = new TypeTable();
            //Console.WriteLine("\nFine till now");
            List <string> files = ProcessCommandline(args);

            foreach (string file in files)   //loops through all the available files
            {
                //Console.WriteLine("\n  Processing file {0}", file);

                ITokenCollection semi = Factory.create();
                //semi.displayNewLines = false;
                if (!semi.open(file as string))
                {
                    throw new Exception("\n  Can't open file!\n\n");
                }
                NameCodeAnalyzer builder = new NameCodeAnalyzer(semi);
                Parser           parser  = builder.build();
                try
                {
                    while (semi.get().Count > 0) //This is where the semi expressions
                    {
                        parser.parse(semi);      //are getting parsed, above we had just defined the parser
                    }
                    //rememeber to remove the comment from the foreach in side parse
                }
                catch (Exception ex)
                {
                    Console.Write("\n\n  {0}\n", ex.Message);
                }
                Repository  rep   = Repository.getInstance();
                List <Elem> table = rep.locations;

                string[] fullname = file.Split('\\');
                string   filename = fullname[fullname.Length - 1];
                //Console.WriteLine("\n\n              Alias Table\n           =============\n");
                //Console.WriteLine("        Name                inFile");
                //Console.WriteLine("       ======               =======\n");
                foreach (var element in table)
                {
                    //Console.WriteLine("Name: {0}  Type: {1}  Filename: {2}", element.name, element.type, filename);
                    //Console.Write("   |  {0}  ", element.name.PadRight(15));
                    //Console.Write("   |  {0}  ", filename.PadRight(10));
                    //Console.Write(" | \n");

                    //if (tt.constains(element.name))

                    //TAB table contains all the different types and all names along with file names

                    tt.add(element.type, filename, element.name);
                }
                //Display.showMetricsTable(table);

                //Console.Write("\n");
                //tt.show();
                semi.close();
            }
            //Console.Write("\n");
            //tt.show();
            return(tt);
        }
Ejemplo n.º 32
0
 // Token: 0x060007AE RID: 1966 RVA: 0x0001CB92 File Offset: 0x0001AD92
 public PSObjectSerializer(TypeTable typeTable)
 {
     this.TypeTable = typeTable;
 }
Ejemplo n.º 33
0
        public void CountUsingExpressionThrowsArgumentNullException()
        {
            var provider = new IProvider();
            var command = new ICommand();
            var schema = new TypeTable(typeof(Customer));

            Expression expression = null;

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandBuilder.Setup(c => c.CreateCountCommand<Customer>(expression)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteCount(command.Object)).Returns(10);

            try
            {
                var target = new DataSession(provider.Object);
                target.Count<Customer>(expression);
            }
            catch (Exception ex)
            {
                
                Assert.IsTrue(ex is ArgumentNullException);
            }
            
            
        }
Ejemplo n.º 34
0
        public void Should_Clear_TypeSelector_List()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add some type selectors to our typetable
            table.AddSelector(stringSelector1);
            table.AddSelector(stringSelector2);

            //Check to see that our table contains at least two items...
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            //Clear all of the string selectors
            table.ClearSelectors<string>();

            //Count the new number of string selectors (should equal zero)
            Assert.AreEqual(0, table.CountSelectors<string>());
        }
Ejemplo n.º 35
0
        public void SaveUpdateThrowsUnableToCreateCommandException()
        {
            var customer = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };

            var provider = new IProvider();
            var transaction = new Mock<ITransaction>();
            var schema = new TypeTable(typeof(Customer));

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(true);


            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandExecutor.Setup(c => c.InitiateTransaction()).Returns(transaction.Object);
            provider.Setup(p => p.GetEntityStatus(customer)).Returns(EntityStatus.Update);
            provider.CommandBuilder.Setup(c => c.CreateUpdateCommand(customer)).Returns(default(Data.ICommand));

            try
            {
                var target = new DataSession(provider.Object);
                target.Save(customer);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is UnableToCreateCommandException);
            }

        }
Ejemplo n.º 36
0
        public void Should_Get_Base_Selector_For_Primitive_Types()
        {
            //Create a new type table which uses all of the system defaults
            var table = new TypeTable();

            //Try to grab the integer selector...
            var intSelector = table.GetBaseSelector(typeof (int));
            Assert.IsInstanceOf<IntSelector>(intSelector);

            //Try to grab the float selector
            var floatSelector = table.GetBaseSelector(typeof (float));
            Assert.IsInstanceOf<FloatSelector>(floatSelector);

            //Try to grab the double selector
            var doubleSelector = table.GetBaseSelector(typeof(double));
            Assert.IsInstanceOf<DoubleSelector>(doubleSelector);

            //Try to grab the string selector
            var stringSelector = table.GetBaseSelector(typeof(string));
            Assert.IsInstanceOf<StringSelector>(stringSelector);

            //Try to grab the DateTime selector
            var dateTimeSelector = table.GetBaseSelector(typeof(DateTime));
            Assert.IsInstanceOf<DateTimeSelector>(dateTimeSelector);

            //Try to grab the Guid selector
            var guidSelector = table.GetBaseSelector(typeof(Guid));
            Assert.IsInstanceOf<GuidSelector>(guidSelector);
        }
Ejemplo n.º 37
0
 internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1)
 {
     this.applicationPrivateDataReceived = new ManualResetEvent(false);
     this.friendlyName = string.Empty;
     if (connectCommands == null)
     {
         throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]");
     }
     if (connectionInfo == null)
     {
         throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo");
     }
     if (connectionInfo is WSManConnectionInfo)
     {
         this.connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy();
     }
     base.instanceId = instanceId;
     base.minPoolSz  = -1;
     base.maxPoolSz  = -1;
     PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) });
     this.connectCommands = connectCommands;
     this.Name            = name;
     base.host            = host;
     this.dispatchTable   = new DispatchTable <object>();
     this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null));
     this.CreateDSHandler(typeTable);
     this.availableForConnection = isDisconnected;
 }
Ejemplo n.º 38
0
 private PhpValue(bool value) : this()
 {
     _type       = TypeTable.BoolTable;
     _value.Bool = value;
 }
Ejemplo n.º 39
0
        private static void GetPagedListByPageEnumExpression(int pageSize, Data.Page page, Expression<Func<Customer, bool>> expression)
        {
            var customer1 = new Customer
            {
                ID = 1,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 1,
                Name = "Customer1",
                ProfileID = 1
            };
            var customer2 = new Customer
            {
                ID = 2,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 2,
                Name = "Customer2",
                ProfileID = 2
            };
            var customer3 = new Customer
            {
                ID = 3,
                Balance = 0,
                BalanceRate = 0,
                DefaultContactID = 3,
                Name = "Customer3",
                ProfileID = 3
            };

            var customerQueue = new Queue<Customer>(new[] { customer1, customer2, customer3 });
            var readerResults = new Queue<bool>(new[] { true, true, true, false });

            var reader = new DbDataReader();
            reader.Setup(r => r.Read()).Returns(readerResults.Dequeue);

            var provider = new IProvider();

            var command = new ICommand();

            var schema = new TypeTable(typeof(Customer));

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);

            provider.CommandBuilder.Setup(c => c.CreateGetListByPageCommand<Customer>(expression)).Returns(command.Object);
            provider.CommandBuilder.Setup(c => c.CreateCountCommand<Customer>(expression)).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteCount(command.Object)).Returns(3);
            provider.CommandExecutor.Setup(c => c.ExecuteReader(command.Object)).Returns(reader.Object);


            provider.Mapper.Setup(m => m.GetTMappingMethod<Customer>()).Returns(d => customerQueue.Dequeue());

            var target = new DataSession(provider.Object);

            try
            {
                var actual = target.GetPagedList<List<Customer>, Customer>(pageSize, page, expression);

                Assert.IsTrue(actual[0].ID == 1 &&
                    actual[1].ID == 2 && actual[2].ID == 3);
            }
            catch (Exception ex)
            {

                Assert.IsTrue(ex is ArgumentNullException);
            }

        }
Ejemplo n.º 40
0
        public void CheckSemantic(DotTypeInvoke node, IScope scope = null)
        {
            CheckSemantic(node.Expression, scope);

            if (node.Expression.ComputedType == null)
            {
                return;
            }

            if (!TypeTable.IsDefinedType(node.AtSign, out var type))
            {
                Logger.LogError(node.Line, node.CharPositionInLine,
                                $"The type '{node.Type}' could not be found");
                return;
            }

            if ((CoolType)node.Expression.ComputedType <= (CoolType)type)
            {
                if (!type.IsDefinedMethod(node.InvokeNode.FuncName, out var method))
                {
                    Logger.LogError(node.Line, node.CharPositionInLine,
                                    $"The name '{node.InvokeNode.FuncName}' does not exist in the {type}'s context");
                    return;
                }

                node.InvokeNode.Method = method;

                //check arguments
                if (node.InvokeNode.Parameters != null)
                {
                    if (node.InvokeNode.Parameters.Children.Count == method.Arguments.Length)
                    {
                        var i = 0;
                        foreach (var parameter in node.InvokeNode.Parameters.Expressions)
                        {
                            CheckSemantic(parameter, scope);

                            if (!((CoolType)method.Arguments[i].Type <= (CoolType)parameter.ComputedType))
                            {
                                Logger.LogError(parameter.Line, parameter.CharPositionInLine,
                                                $"Argument '{i}': cannot convert from '{parameter.ComputedType}' to {method.Arguments[i].Type}");
                            }
                            i++;
                        }
                    }
                    else
                    {
                        Logger.LogError(node.Line, node.CharPositionInLine,
                                        $"No overload for method '{method.Name}' takes '{node.InvokeNode.Children.Count}' arguments");
                    }
                }
                else if (method.Arguments.Length > 0)
                {
                    Logger.LogError(node.Line, node.CharPositionInLine,
                                    $"No overload for method '{method.Name}' takes '0' arguments");
                }

                node.ComputedType = method.ReturnType;
            }

            else
            {
                Logger.LogError(node.Line, node.CharPositionInLine,
                                $"Cannot implicitly convert type '{node.Expression.ComputedType}' to '{type}'");
            }
        }
Ejemplo n.º 41
0
        public void CountAllWithTransactionInitiated()
        {
            var provider = new IProvider();
            var command = new ICommand();
            var schema = new TypeTable(typeof(Customer));

            var transaction = new Mock<ITransaction>();

            provider.Setup(p => p.GetSchema(typeof(Customer))).Returns(schema);
            provider.CommandBuilder.Setup(c => c.CreateCountCommand<Customer>()).Returns(command.Object);
            provider.CommandExecutor.Setup(c => c.InitiateTransaction()).Returns(transaction.Object);
            provider.CommandExecutor.Setup(c => c.ExecuteCount(command.Object, transaction.Object)).Returns(10);

            var target = new DataSession(provider.Object);
            target.BeginTransaction();
            var result = target.Count<Customer>();
            target.CommitTransaction();
            Assert.IsTrue(result == 10);
        }
Ejemplo n.º 42
0
 private PhpValue(TypeTable type) : this()
 {
     _type = type;
     Debug.Assert(IsNull || !IsSet);
 }
Ejemplo n.º 43
0
        public void GenerateCode(ProgramNode node, ICIL_CodeGenerator codeGenerator = null)
        {
            foreach (var cls in new[] { BuiltIn.Object, BuiltIn.IO, BuiltIn.String, BuiltIn.Bool, BuiltIn.Int })
            {
                TypeTable.IsDefinedType($"{cls}", out var type);

                #region .TYPES

                CIL_Type cilType;
                IEnumerable <CIL_FunctionDeclaration> funtions;
                IEnumerable <CIL_Attribute>           attributes;

                //var instance = type.Self.Holder ??
                //               (type.Self.Holder = codeGenerator.DefineVariable());

                //codeGenerator.AddLocalVariable(
                //    new CIL_LocalVariable((Variable)type.Self.Holder));

                switch (cls)
                {
                case BuiltIn.Object:
                    funtions = ((CoolType)type).GetMethods
                               .Select(function => new CIL_FunctionDeclaration($"{function.ParentScope}_{function.Name}"));
                    cilType = CIL_Factory.DefineType($"{cls}", funtion: funtions);
                    break;

                case BuiltIn.IO:
                    funtions = ((CoolType)type).GetMethods
                               .Select(function => new CIL_FunctionDeclaration($"{function.ParentScope}_{function.Name}"));
                    cilType = CIL_Factory.DefineType($"{cls}", $"{BuiltIn.Object}", funtion: funtions);
                    break;

                case BuiltIn.String:
                    attributes = new[] { new CIL_Attribute($"{Attribute.String_value}") };

                    funtions = ((CoolType)type).GetMethods
                               .Select(function => new CIL_FunctionDeclaration($"{function.ParentScope}_{function.Name}"));
                    cilType = CIL_Factory.DefineType($"{cls}", $"{BuiltIn.Object}", attributes, funtions);
                    break;

                case BuiltIn.Int:
                case BuiltIn.Bool:
                    attributes = new[] { new CIL_Attribute($"{cls}_value") };
                    cilType    = CIL_Factory.DefineType($"{cls}", $"{BuiltIn.Object}", attributes);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                CIL_Factory.AddType(cilType);

                #endregion
            }

            #region BFS GenerateCode

            var queue = new Queue <string>();
            queue.Enqueue("Object");
            queue.Enqueue("IO");
            var classesList = new List <ClassNode>();

            while (queue.Count != 0)
            {
                classesList.AddRange(node.ClassesList
                                     .Where(classNode =>
                {
                    var boolean = classNode.TypeParent == queue.Peek();
                    if (boolean)
                    {
                        queue.Enqueue(classNode.TypeClass);
                    }
                    return(boolean);
                }));
                queue.Dequeue();
            }

            #endregion

            foreach (var cls in classesList)
            {
                TypeTable.IsDefinedType(cls.TypeClass, out var type);

                #region .Types

                var attributes = ((CoolType)type).GetAttributes
                                 .Select(attr => new CIL_Attribute($"{cls.TypeClass}_{attr.Name}"));

                var funtions = ((CoolType)type).GetMethods
                               .Select(funtion => new CIL_FunctionDeclaration($"{funtion.ParentScope}_{funtion.Name}"));

                var cilType = CIL_Factory.DefineType(cls.TypeClass, cls.TypeParent, attributes, funtions);

                CIL_Factory.AddType(cilType);

                #endregion
            }

            foreach (var cls in classesList)
            {
                GenerateCode(cls);
            }

            #region .CODE

            #region Object

            CIL_Factory.AddFunction(CIL_FunctionBuilder.Object_copy);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.Object_type_name);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.Object_abort);

            #endregion

            #region IO

            CIL_Factory.AddFunction(CIL_FunctionBuilder.IO_out_string);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.IO_out_int);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.IO_in_string);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.IO_in_int);

            #endregion

            #region String

            CIL_Factory.AddFunction(CIL_FunctionBuilder.String_concat);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.String_length);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.String_substring);

            #endregion

            #region Exceptions

            CIL_Factory.AddFunction(CIL_FunctionBuilder.ExecutionOfACaseStatementWithoutAMatchingBranchException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.CaseOnVoidException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.ArgumentOutOfRangeException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.DispatchOnVoidException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.DivideByZeroException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.NegativeLengthException);
            CIL_Factory.AddFunction(CIL_FunctionBuilder.SubstringOutOfRangeException);

            #endregion

            #endregion
        }
Ejemplo n.º 44
0
    /// <summary>
    /// update Place table
    /// </summary>
    /// <param name="hblid">int</param>
    protected void update_company_type()
    {
        //voyageid
        int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
        //original value for name
        string _oldvalue = this.dxhfOrder.Contains("oldvalue") ? this.dxhfOrder.Get("oldvalue").ToString() : "";
   
        if (_pid > 0)
        {
            try
            {
                //new instance of record
                TypeTable _tbl = new TypeTable(_pid);

                //get values off insert form
                //check duplicate name
                ASPxTextBox _txt = (ASPxTextBox)this.fmvCompanyType.FindControl("dxtxtTypeNameEdit");
                if (_txt != null && _txt.Text != "")
                {  
                    string _newvalue = _txt.Text.Trim().ToString(); //country name
                    bool _duplicate = _newvalue != _oldvalue ? wwi_func.value_exists("TypeName", "TypeTable", _newvalue) : false;

                    if (!_duplicate)
                    {
                        _tbl.TypeName  = _newvalue;
                        
                        //update
                        _tbl.Save();
                    }
                    else
                    {
                        string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                        this.dxlblErr.Text = _ex;
                        this.dxpnlErr.ClientVisible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                string _ex = ex.Message.ToString();
                this.dxlblErr.Text = _ex;
                this.dxpnlErr.ClientVisible = true;
            }
        }
        else
        {
            string _ex = "Can't update record ID = 0";
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }
    }
Ejemplo n.º 45
0
        public static (List <FunctionNode>, List <FunctionNode>, List <TypeDefinitionNode>) BuildAST(functionalParser p, ref TypeTable tt)
        {
            functionalBaseVisitorImpl visitor = new functionalBaseVisitorImpl("main.f", ref tt);

            return(visitor.VisitProgram(p.program()));
        }
Ejemplo n.º 46
0
 private PhpValue(TypeTable type, object obj) : this()
 {
     _type    = (obj != null) ? type : TypeTable.NullTable;
     _obj.Obj = obj;
 }
Ejemplo n.º 47
0
 private PhpValue(double value) : this()
 {
     _type         = TypeTable.DoubleTable;
     _value.Double = value;
 }
Ejemplo n.º 48
0
        internal static RunspacePool[] GetRemoteRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable)
        {
            WSManConnectionInfo wsmanConnectionInfo = connectionInfo as WSManConnectionInfo;

            if (wsmanConnectionInfo == null)
            {
                throw new NotSupportedException();
            }
            List <RunspacePool> list = new List <RunspacePool>();

            foreach (PSObject obj2 in RemoteRunspacePoolEnumeration.GetRemotePools(wsmanConnectionInfo))
            {
                WSManConnectionInfo info2 = wsmanConnectionInfo.Copy();
                PSPropertyInfo      info3 = obj2.Properties["ShellId"];
                PSPropertyInfo      info4 = obj2.Properties["State"];
                PSPropertyInfo      info5 = obj2.Properties["Name"];
                PSPropertyInfo      info6 = obj2.Properties["ResourceUri"];
                if (((info3 != null) && (info4 != null)) && ((info5 != null) && (info6 != null)))
                {
                    string name           = info5.Value.ToString();
                    string str2           = info6.Value.ToString();
                    bool   isDisconnected = info4.Value.ToString().Equals("Disconnected", StringComparison.OrdinalIgnoreCase);
                    Guid   shellId        = Guid.Parse(info3.Value.ToString());
                    if (str2.StartsWith("http://schemas.microsoft.com/powershell/", StringComparison.OrdinalIgnoreCase))
                    {
                        Collection <PSObject> remoteCommands;
                        UpdateWSManConnectionInfo(info2, obj2);
                        info2.EnableNetworkAccess = true;
                        List <ConnectCommandInfo> list2 = new List <ConnectCommandInfo>();
                        try
                        {
                            remoteCommands = RemoteRunspacePoolEnumeration.GetRemoteCommands(shellId, info2);
                        }
                        catch (CmdletInvocationException exception)
                        {
                            if ((exception.InnerException == null) || !(exception.InnerException is InvalidOperationException))
                            {
                                throw;
                            }
                            continue;
                        }
                        foreach (PSObject obj3 in remoteCommands)
                        {
                            PSPropertyInfo info7 = obj3.Properties["CommandId"];
                            PSPropertyInfo info8 = obj3.Properties["CommandLine"];
                            if (info7 != null)
                            {
                                string cmdStr = (info8 != null) ? info8.Value.ToString() : string.Empty;
                                Guid   cmdId  = Guid.Parse(info7.Value.ToString());
                                list2.Add(new ConnectCommandInfo(cmdId, cmdStr));
                            }
                        }
                        RunspacePool item = new RunspacePool(isDisconnected, shellId, name, list2.ToArray(), info2, host, typeTable);
                        list.Add(item);
                    }
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 49
0
 private PhpValue(TypeTable type, object obj)
 {
     _type  = (obj != null) ? type : TypeTable.NullTable;
     _value = default(ValueField);
     _obj   = obj;
 }
Ejemplo n.º 50
0
        public void Should_Add_Type_Selectors_For_Single_Type_To_TypeTable()
        {
            //Create a new TypeTable
            var table = new TypeTable(false);

            //Create some selectors that we're going to add
            var stringSelector1 = new StringSelector();
            var stringSelector2 = new FullNameSelector();
            var stringSelector3 = new EmailSelector();

            Assert.AreEqual(0, table.CountSelectors<string>(), "should have ZERO type selectors for type 'string' since we haven't added any yet");

            //Add the first selector (our default string selector)
            table.AddSelector<string>(stringSelector1);
            Assert.AreEqual(1, table.CountSelectors<string>(), "should have ONE type selectors for type 'string'");

            var firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<StringSelector>(firstselector);

            //Add the second selector (the full name selector)
            table.AddSelector<string>(stringSelector2);
            Assert.AreEqual(2, table.CountSelectors<string>(), "should have TWO type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<FullNameSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!

            //Add the thrid selector (the email address selector)
            table.AddSelector<string>(stringSelector3);
            Assert.AreEqual(3, table.CountSelectors<string>(), "should have THREE type selectors for type 'string'");

            firstselector = table.GetSelectors<string>().First();
            Assert.IsInstanceOf<EmailSelector>(firstselector); //Oh snap, the new front of the line should be our full name selector!
        }
Ejemplo n.º 51
0
 public void CheckSemantic(IsVoidNode node, IScope scope = null)
 {
     CheckSemantic(node.Expression, scope);
     TypeTable.IsDefinedType("Bool", out var booleanType);
     node.ComputedType = booleanType;
 }
 internal InternalMISerializer(int depth)
 {
     _depth = depth;
     // TODO, insivara : Revisit this
     _typeTable = new TypeTable();
 }
Ejemplo n.º 53
0
    protected void bind_formview(string mode)
    {
        //have to use a collection as formview needs to bind to enumerable
        TypeTableCollection _tbl = new TypeTableCollection();
        if (mode != "Insert")
        {
            int _pid = wwi_func.vint(wwi_security.DecryptString(get_token("pid").ToString(), "publiship"));
            TypeTable _ct = new TypeTable(_pid);
            _tbl.Add(_ct);

            //store original value for company type name so we can check against database when saving
            if (this.dxhfOrder.Contains("oldvalue")) { this.dxhfOrder.Remove("oldvalue"); }
            this.dxhfOrder.Add("oldvalue", _ct.TypeName); 
        }
        else
        {
            TypeTable _ct = new TypeTable();
            _tbl.Add(_ct);
        }

        this.fmvCompanyType.DataSource = _tbl;
        this.fmvCompanyType.DataBind();
    }
Ejemplo n.º 54
0
 internal OutOfProcessServerTransportManager(OutOfProcessTextWriter stdOutWriter, Guid powershellInstanceId, TypeTable typeTableToUse, int fragmentSize, PSRemotingCryptoHelper cryptoHelper) : base(fragmentSize, cryptoHelper)
 {
     this.stdOutWriter         = stdOutWriter;
     this.powershellInstanceId = powershellInstanceId;
     base.TypeTable            = typeTableToUse;
 }
Ejemplo n.º 55
0
    //end update

    /// <summary>
    /// new record
    /// </summary>
    protected int insert_company_type()
    {
        int _newid = 0;

        try
        {
            ///new instance of record
            TypeTable _tbl = new TypeTable();
            
            //get values off insert form
            //check for duplicate name
            ASPxTextBox _txt = (ASPxTextBox)this.fmvCompanyType.FindControl("dxtxtTypeNameInsert");
            if (_txt != null && _txt.Text != "")
            {
                string _newvalue = _txt.Text.Trim().ToString(); //country name

                if (!wwi_func.value_exists("TypeName", "TypeTable", _newvalue))
                {
                    _tbl.TypeName = _txt.Text.Trim().ToString();

                    //insert
                    _tbl.Save();
                    //get new id
                    _newid = (int)_tbl.GetPrimaryKeyValue();
                }
                else
                {
                    string _ex = string.Format("{0} is already in database. This record will not be saved", _newvalue);
                    this.dxlblErr.Text = _ex;
                    this.dxpnlErr.ClientVisible = true;
                }
            }
        }
        catch (Exception ex)
        {
            string _ex = ex.Message.ToString();
            this.dxlblErr.Text = _ex;
            this.dxpnlErr.ClientVisible = true;
        }

        return _newid;
    }
Ejemplo n.º 56
0
 /// <summary>
 /// 修改分类信息
 /// </summary>
 /// <param name="type">分类对象</param>
 /// <returns></returns>
 public static bool UpdateType(TypeTable type)
 {
     return(TypeTableDal.UpdateType(type) == 1);
 }
        /// <summary>
        /// Initializes the datastore with the server configuration.
        /// </summary>
        /// <param name="serverDescription">The server description.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="certificateValidator">The certificate validator.</param>
        /// <param name="instanceCertificate">The instance certificate.</param>
        public ServerInternalData(
            ServerProperties                     serverDescription, 
            ApplicationConfiguration             configuration,
            ServiceMessageContext                messageContext,
            CertificateValidator                 certificateValidator,
            X509Certificate2                     instanceCertificate)
        {
            m_serverDescription = serverDescription;
            m_configuration = configuration;
            m_messageContext = messageContext;
            
            m_endpointAddresses = new List<Uri>();

            foreach (string baseAddresses in m_configuration.ServerConfiguration.BaseAddresses)
            {
                Uri url = Utils.ParseUri(baseAddresses);

                if (url != null)
                {
                    m_endpointAddresses.Add(url);
                }
            }
            
            m_namespaceUris = m_messageContext.NamespaceUris;
            m_factory = m_messageContext.Factory;

            m_serverUris = new StringTable();
            m_typeTree = new TypeTable(m_namespaceUris);

#if LEGACY_CORENODEMANAGER
            m_typeSources = new TypeSourceTable();
#endif
                                                
            // add the server uri to the server table.
            m_serverUris.Append(m_configuration.ApplicationUri);

            // create the default system context.
            m_defaultSystemContext = new ServerSystemContext(this);
        }
Ejemplo n.º 58
0
        private void ShowTypeTable(object sender, RoutedEventArgs e)
        {
            var s = new TypeTable();

            s.Show();
        }
	    public void Update(int TypeID,string TypeName,byte[] Ts)
	    {
		    TypeTable item = new TypeTable();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.TypeID = TypeID;
				
			item.TypeName = TypeName;
				
			item.Ts = Ts;
				
	        item.Save(UserName);
	    }
Ejemplo n.º 60
0
 public AccountCloudStorage GetAccountCloudStorage(TypeTable typeTable)
 {
     return(AccountCloudStorages.Single(x => x.TypeTable == typeTable));
 }