public void Submit(FBApi api, Mapping target)
        {
            Log.Verbose(LogCategory, "Submitting new or updated error information to server", null);

            // Start by looking for the fingerprint to decide whether we need
            // to create an new case or update an existing one.
            Dictionary<string, string> args = new Dictionary<string, string>
                           {
                               {"sScoutDescription", Error.Fingerprint},
                           };

            string results = api.Cmd("listScoutCase", args);
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(results);
            XmlNode caseNode = xml.SelectSingleNode("/response/case/ixBug");

            if (caseNode == null)
            {
                Log.Information(LogCategory, "Submitting as new issue because no existing Scout Case could be found with the fingerprint", "Fingerprint: {0}\r\n\r\nRaw Result:\r\n{1}", Error.Fingerprint, results);
                SubmitNew(api, target);
            }
            else
            {
                Log.Information(LogCategory, "Submitting as an update because an existing Scout Case matched the fingerprint", "Fingerprint: {0}\r\n\r\nRaw Result:\r\n{1}", Error.Fingerprint, results);
                SubmitUpdate(api, caseNode.InnerText);
            }
        }
		public PocoComponentTuplizer(Mapping.Component component) : base(component)
		{
			componentClass = component.ComponentClass;

			var parentProperty = component.ParentProperty;
			if (parentProperty == null)
			{
				parentSetter = null;
				parentGetter = null;
			}
			else
			{
				parentSetter = parentProperty.GetSetter(componentClass);
				parentGetter = parentProperty.GetGetter(componentClass);
			}

			if (hasCustomAccessors || !Cfg.Environment.UseReflectionOptimizer)
			{
				optimizer = null;
			}
			else
			{
				optimizer = Cfg.Environment.BytecodeProvider.GetReflectionOptimizer(componentClass, getters, setters);
			}
		}
Example #3
0
        public Interface(Mapping.Interface iface, DataCenter[] dataCenters = null, IpAddress[] ips = null)
        {
            this.Id = iface.Id;
            this.DataCenterId = iface.DataCenterId;
            if (dataCenters != null)
                this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == iface.DataCenterId);
            this.Created = iface.Created;
            this.LastUpdated = iface.LastUpdated;
            if (iface.Num != null)
                this.Index = Convert.ToInt32(iface.Num);
            this.Status = Converter.ToInterfaceStatus(iface.State);
            this.Bandwidth = iface.Bandwidth;
            this.Type = Converter.ToInterfaceType(iface.Type);
            if (iface.VirtualMachineId != null)
                this.VirtualMachineId = Convert.ToInt32(iface.VirtualMachineId);
            this.VirtualMachine = null;
            this.IpAddressIds = iface.IpAddressIds;
            if (ips != null)
            {
                List<IpAddress> ipList = new List<IpAddress>();
                foreach (int ipId in iface.IpAddressIds)
                {
                    IpAddress ipAddress = ips.SingleOrDefault(i => i.Id == ipId);

                    if (ipAddress.Interface == null)
                        ipAddress.Interface = this;

                    ipList.Add(ipAddress);
                }
                this.IpAddresses = ipList.ToArray();
            }
        }
Example #4
0
        public MappingEntry(Mapping mapping, ExcelWorksheet sourceWorksheet, int index)
        {
            var contentMapping = mapping as ContentMapping;
            var movableMapping = mapping as MovableMapping;
            var cellMapping = mapping as CellMapping;
            var formulaMapping = mapping as FormulaMapping;

            if (contentMapping != null)
                Value = contentMapping.GetValue();
            else if (movableMapping != null)
                Value = movableMapping.GetValue(index, sourceWorksheet);
            else if (cellMapping != null)
                Value = cellMapping.GetValue(sourceWorksheet);
            else if (formulaMapping != null)
            {
                IsFormula = true;
                Value = formulaMapping.GetValue();
            }
            else
                throw new InvalidOperationException("Nieznany rodzaj próbki.");

            Mapping = mapping;

            if (mapping.IsDateColumnMapping() && Value != null) 
            	Value = ExcelHelper.ToDate(Value, Mapping.Sample.Card.DateFormats.ToArray());
        }
		public OneToManyPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, ISessionFactoryImplementor factory)
			: base(collection, cache, cfg, factory)
		{
			_cascadeDeleteEnabled = collection.Key.IsCascadeDeleteEnabled && factory.Dialect.SupportsCascadeDelete;
			_keyIsNullable = collection.Key.IsNullable;
			_keyIsUpdateable = collection.Key.IsUpdateable;
		}
		public BasicCollectionPersister(
			Mapping.Collection collection,
			ICacheConcurrencyStrategy cache,
			ISessionFactoryImplementor factory)
			: base(collection, cache, factory)
		{
		}
Example #7
0
        public bool Execute(string directory, Mapping mapToRun, BuildData buildData)
        {
            try
            {
                DeploymentHost host = new DeploymentHost();
                Runspace space = RunspaceFactory.CreateRunspace(host);
                space.Open();

                this.PopulateVariables(space, mapToRun, buildData);

                string command = this.GeneratePipelineCommand(directory, mapToRun);
                this._scriptRun = command;

                this.EnsureExecutionPolicy(space);
                Pipeline pipeline = space.CreatePipeline(command);
                Collection<PSObject> outputObjects = pipeline.Invoke();

                if (pipeline.PipelineStateInfo.State != PipelineState.Failed)
                {
                    this._errorOccured = false;
                }

                string output = this.GenerateOutputFromObjects(outputObjects);
                this._output = output;

                space.Close();
            }
            catch (Exception ex)
            {
                this._errorOccured = true;
                this._output = ex.ToString();
            }

            return this.ErrorOccured;
        }
        public void RegisterMapping(ICompilerInputContract contract, ICompilerInputContractMapping dataRowContractMapping)
        {
            var properties = contract.Properties.Select(p => new CompilerInputContractProperty(p)).ToList();
            var fieldMappings = dataRowContractMapping.Mapping.ToList();

            var ixPropertyNames = new HashSet<string>(this.m_columnInfos.Select(c => c.ColumnName), StringComparer.OrdinalIgnoreCase);

            //if (fieldMappings.Count > properties.Count)
            //{
            //    m_compilerOutputBuilder.AddError(
            //        m_compilerNotificationMessageBuilder.TooFewTableTypeInterfaceMappingItems(m_fullName, contract.InterfaceName, properties.Count, fieldMappings.Count));
            //}

            var unexpectedColumnMappingNames = fieldMappings.Where(m => !(this.m_ixColumnNames.Contains(m.DataFieldName)));

            var mapping = new Mapping<DataColumnInfo, CompilerInputContractProperty>(
                dataRowContractMapping
                .Mapping
                .ToDictionary(m => m.DataFieldName, m => m.ContractPropertyName, StringComparer.Ordinal));

            var pairs = mapping.Map(this.m_columnInfos, properties);

            foreach (var pair in pairs)
            {
                this.m_interfaceMappings.Add(
                    new CompilerOutputInterfacePropertyMapping
                    {
                        InterfaceName = dataRowContractMapping.InterfaceName,
                        ColumnName = pair.Source.ColumnName,
                        PropertyName = pair.Target.PropertyName,
                        PropertyType = pair.Target.PropertyType
                    });
            }
        }
        public DialogResult EditMapping(Dictionary<string, List<String>> productsAndApplications, 
            Dictionary<string, List<String>> projectsAndAreas,
            Dictionary<int, string> priorities,
            Mapping existingMapping)
        {
            Text = EditMappingTitle;

            m_ProductsAndApplications = productsAndApplications;
            m_ProjectsAndAreas = projectsAndAreas;
            m_Priorities = priorities;

            DisplayProductsAndApplications();
            DisplayPriorities();
            DisplayProjectsAndAreas();

            //display the current mapping values
            ProductSelection.Text = existingMapping.Product;
            ApplicationSelection.Text = existingMapping.Application;
            txtVersions.Text = existingMapping.Versions;

            ProjectSelection.SelectedItem = existingMapping.Project;
            AreaSelection.SelectedItem = existingMapping.Area;
            PrioritySelection.SelectedValue = existingMapping.Priority;

            DialogResult result = ShowDialog();
            if (result == DialogResult.OK)
            {
                UpdateData(existingMapping);
            }

            return result;
        }
		/// <summary>
		/// Generates a VersionProperty representation for an entity mapping given its
		/// version mapping Property.
		/// </summary>
		/// <param name="property">The version mapping Property.</param>
		/// <param name="lazyAvailable">Is property lazy loading currently available.</param>
		/// <returns>The appropriate VersionProperty definition.</returns>
		public static VersionProperty BuildVersionProperty(Mapping.Property property, bool lazyAvailable)
		{
			String mappedUnsavedValue = ((IKeyValue) property.Value).NullValue;

			VersionValue unsavedValue = UnsavedValueFactory.GetUnsavedVersionValue(
				mappedUnsavedValue,
				GetGetter(property),
				(IVersionType) property.Type,
				GetConstructor(property.PersistentClass)
				);

			bool lazy = lazyAvailable && property.IsLazy;

			return new VersionProperty(
				property.Name,
				property.NodeName,
				property.Value.Type,
				lazy,
				property.IsInsertable,
				property.IsUpdateable,
				property.Generation == PropertyGeneration.Insert || property.Generation == PropertyGeneration.Always,
				property.Generation == PropertyGeneration.Always,
				property.IsOptional,
				property.IsUpdateable && !lazy,
				property.IsOptimisticLocked,
				property.CascadeStyle,
				unsavedValue
				);
		}
        public DialogResult AddMapping(Dictionary<string, List<String>> productsAndApplications, 
            Dictionary<string, List<String>> projectsAndAreas, 
            Dictionary<int, string> priorities, 
            out Mapping newMapping)
        {
            Text = AddMappingTitle;

            m_ProductsAndApplications = productsAndApplications;
            m_ProjectsAndAreas = projectsAndAreas;
            m_Priorities = priorities;

            newMapping = null;

            DisplayProductsAndApplications();
            DisplayPriorities();
            DisplayProjectsAndAreas();

            DialogResult result = ShowDialog();
            if (result == DialogResult.OK)
            {
                newMapping = new Mapping();
                UpdateData(newMapping);
            }

            return result;
        }
Example #12
0
        public SqlMapperTransformer(Mapping mapping, Evaluant.Uss.Models.Model model)
        {
            _Mapping = mapping;
            _Model = model;
            _ExprLevel = new Stack();

            _AliasColumnMapping = new Hashtable();
            _IsAliasColumnComputed = false;

            // Add "Type" and "Id" field. Avoid duplicated field if mapping model contains these two keyword fields.
            //            _AliasColumnMapping.Add("Type", "Type");

            foreach (EntityMapping em in mapping.Entities)
            {
                if (em.DiscriminatorField == null || em.DiscriminatorField == string.Empty)
                    continue;

                if (_AliasColumnMapping.ContainsKey(em.DiscriminatorField))
                    continue;

                _AliasColumnMapping.Add(em.DiscriminatorField, em.DiscriminatorField);
            }

            //_AliasColumnMapping.Add("Id", "Id");
        }
 public void mappings_can_be_added()
 {
     var converter = new MapConverter();
     var mapping = new Mapping("from", "to");
     converter.Mappings.Add(mapping);
     Assert.True(converter.Mappings.Contains(mapping));
 }
Example #14
0
        protected override string BuildTableScript(Mapping.IEntityMapping mapping)
        {
            var tableName = GetTableName(mapping);
            var sb = new StringBuilder(512);
            sb.Append("CREATE TABLE ").Append(tableName).Append("(");

            int num = 0;
            foreach (var f in mapping.Members.Where(p => !p.IsRelationship && !p.IsComputed))
            {
                if (num > 0)
                    sb.Append(",");
                sb.AppendLine();

                sb.Append("\t").Append(Dialect.Quote(f.ColumnName));

                var sqlType = f.SqlType;
                sb.Append(" ").Append(GetDbType(f.SqlType));

                if (sqlType.Required || f.IsPrimaryKey)
                    sb.Append(" NOT NULL");

                if (f.IsGenerated)
                    sb.Append(GetDefaultValue(f, sqlType));
                num++;
            }

            sb.AppendLine()
                .Append(")");
            sb.AppendLine("");
            return sb.ToString();
        }
        /// <summary>
        /// Add a specific resource.
        /// </summary>
        /// <param name="path">Path (Uri) requested by clients</param>
        /// <param name="assembly">Assembly that the resources exist in</param>
        /// <param name="rootNameSpace">Name space to root folder under (all name spaces below the specified one are considered as folders)</param>
        /// <param name="fullResourceName">Name space and name of resource.</param>
        /// <example>
        /// <code>
        /// Add("/", Assembly.GetExecutingAssembly(), "MyApplication.Files", "Myapplication.Files.Images.MyImage.png");
        /// </code>
        /// </example>
        public void Add(string path, Assembly assembly, string rootNameSpace, string fullResourceName)
        {
            if (!path.EndsWith("/"))
                path += "/";

            var mapping = new Mapping { Assembly = assembly, FullResourceName = fullResourceName };

            string filePath = fullResourceName.Remove(0, rootNameSpace.Length + 1);

            int extensionPos = filePath.LastIndexOf(".", StringComparison.Ordinal);
            if (extensionPos == -1)
                return;

            int nextPos = filePath.LastIndexOf(".", extensionPos - 1, StringComparison.Ordinal);
            if (nextPos != -1)
            {
                string typeExtension = filePath.Substring(nextPos + 1, extensionPos - nextPos - 1);
                if (typeExtension == "xml" || typeExtension == "json" || typeExtension == "js")
                    mapping.TypeExtension = typeExtension;
            }

            if (string.IsNullOrEmpty(mapping.TypeExtension))
                nextPos = extensionPos;

            // TODO: next thing is to set the language. But not today.
            // /users/list.1053.xml.spark <--- language 1053, view for xml, spark is the view engine.
            filePath = filePath.Substring(0, nextPos).Replace(".", "/") + filePath.Substring(extensionPos);

            mapping.FileName = Path.GetFileName(filePath).ToLower();
            mapping.UriPath = (path + filePath).Replace('\\', '/').ToLower();

            _logger.Trace("Adding mapping '" + path + filePath + "' to resource '" + fullResourceName + "' assembly '" + assembly + "'.");
            _mappings.Add(path.ToLower() + filePath.ToLower(), mapping);
        }
Example #16
0
		static void Init()
		{
			string[] wrk = "C,D,E,F,G,H,I,J,K,L,M,N,O.P,Q,R,S,T,U,V,W,X,Y,Z,C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1,O.P1,Q1,R1,S1,T1,U1,V1,W1,X1,Y1,Z1,".Split(new char[] {','});
			mFS = new Mapping[wrk.Length];
			for (int i = 0; i < wrk.Length; i++) mFS[i] = new Mapping(wrk[i]);
			doneInit = true;
		}
Example #17
0
        public SqlMapperPersistenceEngine(string connectionString, IDriver driver, DBDialect dialect, Mapping mapping, ArrayList cacheEntries, Models.Model model)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (driver == null)
            {
                throw new ArgumentNullException("driver");
            }
            if (dialect == null)
            {
                throw new ArgumentNullException("dialect");
            }
            if (mapping == null)
            {
                throw new ArgumentNullException("mapping");
            }
            this.Driver = driver;
            this.Dialect = dialect;
            this._Mapping = mapping;
            this._Connection = this._Driver.CreateConnection(connectionString);

            if (_Connection is Evaluant.Uss.Data.FileClient.FileConnection)
            {
                ((Evaluant.Uss.Data.FileClient.FileConnection)_Connection).Dialect = dialect;
            }

            base._Model = model;
            this._CacheEntries = cacheEntries;
            this.Initialize();
        }
Example #18
0
		public string FindMappingFile(string filename, Mapping mapType)
		{
			var sb = new StringBuilder(Material.TextureNameBufferLength);

			this.FindMappingFile(sb, filename, mapType);

			return sb.ToString();
		}
Example #19
0
 public static Mapping FromDescriptor(dynamic spec)
 {
     Mapping mapping = new Mapping();
     mapping.Backend = spec.ContainsKey("Backend") ? spec["Backend"] : null;
     mapping.Frontend = spec.ContainsKey("Frontend") ? spec["Frontend"] : null;
     mapping.Options = spec.ContainsKey("Options") ? spec["Options"] : null;
     return mapping;
 }
 public void Setup()
 {
     mainPanel = MockRepository.GenerateStub<IMainPanel>();
     form = MockRepository.GenerateMock<IMappingForm>();
     mapping = MockRepository.GenerateStub<Mapping>();
     mapping.MappingSet = new MappingSetImpl();
     //presenter = new MappingPresenter(mainPanel, form);
 }
 public void ctor_that_takes_from_and_to_sets_from_and_to()
 {
     var from = new object();
     var to = new object();
     var mapping = new Mapping(from, to);
     Assert.Same(from, mapping.From);
     Assert.Same(to, mapping.To);
 }
 public ManyToManyAttribute( Type childType, Mapping.Loading loading, Cascade cascade )
     : base()
 {
     this.ChildReturnType = childType;
     this.Linked = true;
     this.Loading = loading;
     this.Cascade = cascade;
 }
 /// <summary>
 /// Instantiates a new instance of the <see cref="T:ManyToManyAttribute"/> defining a many to many relationship.
 /// </summary>
 /// <param name="childTable">The table name of the child.</param>
 /// <param name="linkingTable">The table name of the linking table between the parent and child.</param>
 /// <param name="childType">The <see cref="T:Type"/> of child.</param>
 /// <param name="loading">The <see cref="T:Loading"/> behavior to use for this member.</param>
 public ManyToManyAttribute( string childTable, string linkingTable, Type childType, Mapping.Loading loading )
     : base()
 {
     this.ChildReturnType = childType;
     this.Name = childTable;
     this.Linked = true;
     this.LinkName = linkingTable;
     this.Loading = loading;
 }
Example #24
0
 private void AddCollectionSecondPass(XmlNode node, Mapping.Collection model)
 {
     mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses)
         {
             PreCollectionSecondPass(model);
             BindCollectionSecondPass(node, model, persistentClasses);
             PostCollectionSecondPass(model);
         });
 }
Example #25
0
 public void TestMappings()
 {
     var stud = POCOFactory.GenerateSingleStudent();
     //AutoMapper.Mapper.CreateMap<Student, StudentDTO>();
     //var dto = AutoMapper.Mapper.Map<Student, StudentDTO>(stud);
     var mapper = new Mapping();
     var dto  = mapper.MapEntity<StudentDTO, Student>(stud);
     Assert.IsNotNull(dto);
 }
 public void from_assigns_given_value()
 {
     var mapping = new Mapping();
     var from = new object();
     mapping.From = from;
     Assert.Same(from, mapping.From);
     mapping.From = null;
     Assert.Null(mapping.From);
 }
 public void Setup()
 {
     modification = new UseFieldForAssociationStorage(property => "foo");
     mapping = new CustomerMapping();
     mapping.HasMany(x => x.Orders);
     mapping.HasOne(x => x.Company);
     mapping.BelongsTo(x => x.Company);
     mapping.HasOne(x => x.Company).Storage("baz");
 }
 public static void TestMapping(Mapping mapping, ITable table, Entity entity)
 {
     Assert.That(mapping.FromTable, Is.SameAs(table));
     Assert.That(mapping.ToEntity, Is.SameAs(entity));
     Assert.That(mapping.FromColumns.Count, Is.EqualTo(1));
     Assert.That(mapping.ToProperties.Count, Is.EqualTo(1));
     Assert.That(mapping.FromColumns[0], Is.SameAs(table.Columns[0]));
     Assert.That(mapping.ToProperties[0], Is.EqualTo(entity.Properties.ElementAt(0)));
 }
        public InterfaceOperation(Mapping.InterfaceOperation operation, Interface iface, IpAddress ipAddress = null)
            : base(operation)
        {
            this.InterfaceId = operation.InterfaceId;
            this.Interface = iface;

            this.IpAddressId = operation.IpAddressId;
            this.IpAddress = ipAddress;
        }
 public void to_assigns_given_value()
 {
     var mapping = new Mapping();
     var to = new object();
     mapping.To = to;
     Assert.Same(to, mapping.To);
     mapping.To = null;
     Assert.Null(mapping.To);
 }
 protected virtual void FromViewModelToEntity(TEV viewModel, TSetting entity)
 {
     Mapping.Map(viewModel, entity);
 }
Example #32
0
 public override string GetVersion(Mapping mapping)
 {
     return("None");
 }
Example #33
0
        /// <summary>
        /// Maps an object to a specific BsonValue type.
        /// </summary>
        /// <param name="value">An object.</param>
        /// <param name="bsonType">The BsonType to map to.</param>
        /// <returns>A BsonValue of the desired type (or BsonNull.Value if value is null and bsonType is Null).</returns>
        public static BsonValue MapToBsonValue(object value, BsonType bsonType)
        {
            string message;

            if (value == null)
            {
                if (bsonType == BsonType.Null)
                {
                    return(BsonNull.Value);
                }
                else
                {
                    message = string.Format("C# null cannot be mapped to BsonType.{0}.", bsonType);
                    throw new ArgumentException(message, "value");
                }
            }

            // handle subclasses of BsonDocument (like QueryDocument) correctly
            if (bsonType == BsonType.Document)
            {
                var bsonDocument = value as BsonDocument;
                if (bsonDocument != null)
                {
                    return(bsonDocument);
                }
            }

            var valueType = value.GetType();

            if (valueType.IsEnum)
            {
                valueType = Enum.GetUnderlyingType(valueType);
                switch (Type.GetTypeCode(valueType))
                {
                case TypeCode.Byte: value = (int)(byte)value; break;

                case TypeCode.Int16: value = (int)(short)value; break;

                case TypeCode.Int32: value = (int)value; break;

                case TypeCode.Int64: value = (long)value; break;

                case TypeCode.SByte: value = (int)(sbyte)value; break;

                case TypeCode.UInt16: value = (int)(ushort)value; break;

                case TypeCode.UInt32: value = (long)(uint)value; break;

                case TypeCode.UInt64: value = (long)(ulong)value; break;
                }
                valueType = value.GetType();
            }

            Conversion conversion; // the conversion (if it exists) that will convert value to bsonType

            if (__fromToMappings.TryGetValue(Mapping.FromTo(valueType, bsonType), out conversion))
            {
                return(Convert(value, conversion));
            }

            // these coercions can't be handled by the conversions table (because of the interfaces)
            switch (bsonType)
            {
            case BsonType.Array:
                if (value is IEnumerable)
                {
                    return(new BsonArray((IEnumerable)value));
                }
                break;

            case BsonType.Document:
                if (value is IDictionary <string, object> )
                {
                    return(new BsonDocument((IDictionary <string, object>)value));
                }
                if (value is IDictionary)
                {
                    return(new BsonDocument((IDictionary)value));
                }
                break;
            }

            message = string.Format(".NET type {0} cannot be mapped to BsonType.{1}.", value.GetType().FullName, bsonType);
            throw new ArgumentException(message, "value");
        }
 public void Delete(GenreDTO genre)
 {
     _genreRepository.Delete(Mapping.GenreFromBlToDal(genre));
 }
 public ExistsInDbState WithParameters(Mapping mappings, InboundMessage inboundMessage)
 {
     _inboundMessage = inboundMessage;
     _mappings       = mappings;
     return(this);
 }
Example #36
0
 private ICSharpCode.Data.EDMDesigner.Core.EDMObjects.MSL.EntityType.PropertyMapping GetBusinessPropertyMapping(EntityType table)
 {
     return(Mapping.GetSpecificMappingForTable(table).FirstOrDefault(pm => pm.Property == Property));
 }
Example #37
0
 public DeletePortMappingRequestMessage(Mapping mapping)
 {
     _mapping = mapping;
 }
Example #38
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DataElement;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (UrlElement != null)
                {
                    dest.UrlElement = (Hl7.Fhir.Model.FhirUri)UrlElement.DeepCopy();
                }
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (VersionElement != null)
                {
                    dest.VersionElement = (Hl7.Fhir.Model.FhirString)VersionElement.DeepCopy();
                }
                if (NameElement != null)
                {
                    dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.ConformanceResourceStatus>)StatusElement.DeepCopy();
                }
                if (ExperimentalElement != null)
                {
                    dest.ExperimentalElement = (Hl7.Fhir.Model.FhirBoolean)ExperimentalElement.DeepCopy();
                }
                if (PublisherElement != null)
                {
                    dest.PublisherElement = (Hl7.Fhir.Model.FhirString)PublisherElement.DeepCopy();
                }
                if (Contact != null)
                {
                    dest.Contact = new List <Hl7.Fhir.Model.DataElement.ContactComponent>(Contact.DeepCopy());
                }
                if (DateElement != null)
                {
                    dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
                }
                if (UseContext != null)
                {
                    dest.UseContext = new List <Hl7.Fhir.Model.CodeableConcept>(UseContext.DeepCopy());
                }
                if (CopyrightElement != null)
                {
                    dest.CopyrightElement = (Hl7.Fhir.Model.FhirString)CopyrightElement.DeepCopy();
                }
                if (StringencyElement != null)
                {
                    dest.StringencyElement = (Code <Hl7.Fhir.Model.DataElement.DataElementStringency>)StringencyElement.DeepCopy();
                }
                if (Mapping != null)
                {
                    dest.Mapping = new List <Hl7.Fhir.Model.DataElement.MappingComponent>(Mapping.DeepCopy());
                }
                if (Element != null)
                {
                    dest.Element = new List <Hl7.Fhir.Model.ElementDefinition>(Element.DeepCopy());
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Example #39
0
 public string GetFileExtension(Mapping mapping)
 {
     return(".ts");
 }
Example #40
0
 protected internal Command(Mapping mapping, NpgsqlCommand command)
 {
     this.Mapping       = mapping;
     this.NpgsqlCommand = command;
 }
Example #41
0
        // Called every time a new input report has arrived
        protected virtual void On_Report(object sender, EventArgs e)
        {
            DS4Device device = (DS4Device)sender;

            int ind = -1;

            for (int i = 0, arlength = DS4_CONTROLLER_COUNT; ind == -1 && i < arlength; i++)
            {
                DS4Device tempDev = DS4Controllers[i];
                if (tempDev != null && device == tempDev)
                {
                    ind = i;
                }
            }

            if (ind != -1)
            {
                if (getFlushHIDQueue(ind))
                {
                    device.FlushHID();
                }

                if (!string.IsNullOrEmpty(device.error))
                {
                    LogDebug(device.error);
                }

                if (inWarnMonitor[ind])
                {
                    int flashWhenLateAt = getFlashWhenLateAt();
                    if (!lag[ind] && device.Latency >= flashWhenLateAt)
                    {
                        lag[ind] = true;
                        device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                        {
                            LagFlashWarning(ind, true);
                        }), null);
                    }
                    else if (lag[ind] && device.Latency < flashWhenLateAt)
                    {
                        lag[ind] = false;
                        device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                        {
                            LagFlashWarning(ind, false);
                        }), null);
                    }
                }
                else
                {
                    if (DateTime.UtcNow - device.firstActive > TimeSpan.FromSeconds(5))
                    {
                        inWarnMonitor[ind] = true;
                    }
                }

                device.getExposedState(ExposedState[ind], CurrentState[ind]);
                DS4State cState = CurrentState[ind];
                device.getPreviousState(PreviousState[ind]);
                DS4State pState = PreviousState[ind];

                if (!device.firstReport && device.IsAlive())
                {
                    device.firstReport = true;
                    device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                    {
                        OnDeviceStatusChanged(this, ind);
                    }), null);
                }
                else if (pState.Battery != cState.Battery || device.oldCharging != device.isCharging())
                {
                    byte tempBattery  = currentBattery[ind] = cState.Battery;
                    bool tempCharging = charging[ind] = device.isCharging();
                    device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                    {
                        OnBatteryStatusChange(this, ind, tempBattery, tempCharging);
                    }), null);
                }

                if (getEnableTouchToggle(ind))
                {
                    CheckForTouchToggle(ind, cState, pState);
                }

                cState = Mapping.SetCurveAndDeadzone(ind, cState);

                if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
                                        containsCustomAction(ind) || containsCustomExtras(ind) ||
                                        getProfileActionCount(ind) > 0))
                {
                    Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
                    cState = MappedState[ind];
                }

                if (!useDInputOnly[ind])
                {
                    x360Bus.Parse(cState, processingData[ind].Report, ind);
                    // We push the translated Xinput state, and simultaneously we
                    // pull back any possible rumble data coming from Xinput consumers.
                    if (x360Bus.Report(processingData[ind].Report, processingData[ind].Rumble))
                    {
                        byte Big   = processingData[ind].Rumble[3];
                        byte Small = processingData[ind].Rumble[4];

                        if (processingData[ind].Rumble[1] == 0x08)
                        {
                            setRumble(Big, Small, ind);
                        }
                    }
                }

                // Output any synthetic events.
                Mapping.Commit(ind);

                // Update the GUI/whatever.
                DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]);
            }
        }
Example #42
0
        public string GetInputkeys(int ind)
        {
            DS4State        cState = CurrentState[ind];
            DS4StateExposed eState = ExposedState[ind];
            Mouse           tp     = touchPad[ind];
            string          result = "nothing";

            if (DS4Controllers[ind] != null)
            {
                if (Mapping.getBoolButtonMapping(cState.Cross))
                {
                    result = "Cross";
                }
                else if (Mapping.getBoolButtonMapping(cState.Circle))
                {
                    result = "Circle";
                }
                else if (Mapping.getBoolButtonMapping(cState.Triangle))
                {
                    result = "Triangle";
                }
                else if (Mapping.getBoolButtonMapping(cState.Square))
                {
                    result = "Square";
                }
                else if (Mapping.getBoolButtonMapping(cState.L1))
                {
                    result = "L1";
                }
                else if (Mapping.getBoolTriggerMapping(cState.L2))
                {
                    result = "L2";
                }
                else if (Mapping.getBoolButtonMapping(cState.L3))
                {
                    result = "L3";
                }
                else if (Mapping.getBoolButtonMapping(cState.R1))
                {
                    result = "R1";
                }
                else if (Mapping.getBoolTriggerMapping(cState.R2))
                {
                    result = "R2";
                }
                else if (Mapping.getBoolButtonMapping(cState.R3))
                {
                    result = "R3";
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadUp))
                {
                    result = "Up";
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadDown))
                {
                    result = "Down";
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadLeft))
                {
                    result = "Left";
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadRight))
                {
                    result = "Right";
                }
                else if (Mapping.getBoolButtonMapping(cState.Share))
                {
                    result = "Share";
                }
                else if (Mapping.getBoolButtonMapping(cState.Options))
                {
                    result = "Options";
                }
                else if (Mapping.getBoolButtonMapping(cState.PS))
                {
                    result = "PS";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, true))
                {
                    result = "LS Right";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, false))
                {
                    result = "LS Left";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, true))
                {
                    result = "LS Down";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, false))
                {
                    result = "LS Up";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, true))
                {
                    result = "RS Right";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, false))
                {
                    result = "RS Left";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, true))
                {
                    result = "RS Down";
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, false))
                {
                    result = "RS Up";
                }
                else if (Mapping.getBoolTouchMapping(tp.leftDown))
                {
                    result = "Touch Left";
                }
                else if (Mapping.getBoolTouchMapping(tp.rightDown))
                {
                    result = "Touch Right";
                }
                else if (Mapping.getBoolTouchMapping(tp.multiDown))
                {
                    result = "Touch Multi";
                }
                else if (Mapping.getBoolTouchMapping(tp.upperDown))
                {
                    result = "Touch Upper";
                }
            }

            return(result);
        }
 public void Update(GenreDTO genre)
 {
     _genreRepository.Update(Mapping.GenreFromBlToDal(genre));
 }
Example #44
0
        public static bool shiftMod(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState)
        {
            bool shift;

            switch (Global.getShiftModifier(deviceNum))
            {
            case 1: shift = Mapping.getBoolMapping(DS4Controls.Cross, cState, eState); break;

            case 2: shift = Mapping.getBoolMapping(DS4Controls.Circle, cState, eState); break;

            case 3: shift = Mapping.getBoolMapping(DS4Controls.Square, cState, eState); break;

            case 4: shift = Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState); break;

            case 5: shift = Mapping.getBoolMapping(DS4Controls.Options, cState, eState); break;

            case 6: shift = Mapping.getBoolMapping(DS4Controls.Share, cState, eState); break;

            case 7: shift = Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState); break;

            case 8: shift = Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState); break;

            case 9: shift = Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState); break;

            case 10: shift = Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState); break;

            case 11: shift = Mapping.getBoolMapping(DS4Controls.PS, cState, eState); break;

            case 12: shift = Mapping.getBoolMapping(DS4Controls.L1, cState, eState); break;

            case 13: shift = Mapping.getBoolMapping(DS4Controls.R1, cState, eState); break;

            case 14: shift = Mapping.getBoolMapping(DS4Controls.L2, cState, eState); break;

            case 15: shift = Mapping.getBoolMapping(DS4Controls.R2, cState, eState); break;

            case 16: shift = Mapping.getBoolMapping(DS4Controls.L3, cState, eState); break;

            case 17: shift = Mapping.getBoolMapping(DS4Controls.R3, cState, eState); break;

            case 18: shift = Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState); break;

            case 19: shift = Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState); break;

            case 20: shift = Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState); break;

            case 21: shift = Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState); break;

            case 22: shift = Mapping.getBoolMapping(DS4Controls.GyroZNeg, cState, eState); break;

            case 23: shift = Mapping.getBoolMapping(DS4Controls.GyroZPos, cState, eState); break;

            case 24: shift = Mapping.getBoolMapping(DS4Controls.GyroXPos, cState, eState); break;

            case 25: shift = Mapping.getBoolMapping(DS4Controls.GyroXNeg, cState, eState); break;

            case 26: shift = device.getCurrentState().Touch1; break;

            default: shift = false; break;
            }
            return(shift);
        }
 public GenreDTO Get(int Id)
 {
     return(Mapping.GenreFromDalToBl(_genreRepository.Get(Id)));
 }
        public string Generate(Mapping mapping)
        {
            if (mapping.IsEnum)
            {
                return(null);
            }

            StringBuilder builder        = new StringBuilder();
            Type          type           = mapping.Fetch();
            string        outputTypeName = mapping.Name;
            string        inputTypeName  = $"{Singleton.Instance.InputArgs.ClassPrefix ?? ""}{type.Name}{Singleton.Instance.InputArgs.ClassPostfix ?? ""}";
            string        methodName     = GetRemotePopulatorDTOMethodName(outputTypeName);

            builder.AppendLine($"public static {outputTypeName} {methodName} ({inputTypeName} remote, {outputTypeName} local = null) {{");
            builder.AppendLine($"\tif (local == null) {{local = new {outputTypeName}();}}");

            foreach (var propertyMapping in mapping.Mappings)
            {
                string localPropertyName  = String.IsNullOrWhiteSpace(propertyMapping.TransformName) ? propertyMapping.Name : propertyMapping.TransformName;
                string remotePropertyName = propertyMapping.Name;

                string localPropertyType  = propertyMapping.Type.IsASimpleType() ? propertyMapping.Type : Singleton.Instance.InputArgs.ClassPrefix + propertyMapping.Type + Singleton.Instance.InputArgs.ClassPostfix;
                string remotePropertyType = propertyMapping.Type;

                if (type.GetProperty(remotePropertyName) == null || type.GetProperty(remotePropertyName).SetMethod == null)
                {
                    continue;
                }

                if (propertyMapping.IsEnum || type.IsNullableEnum())
                {
                    Type enumType = Helpers.GetUnderlyingType(type);

                    if (propertyMapping.Type.IsASimpleType())
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = remote.{remotePropertyName}; }}");
                    }
                    else if (propertyMapping.IsNullable)
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = ({remotePropertyType}) Enum.Parse(typeof({remotePropertyType}), remote.{remotePropertyName}.ToString() ); }}");
                    }
                    else
                    {
                        builder.AppendLine($"\tlocal.{localPropertyName} = ({remotePropertyType}) Enum.Parse(typeof({remotePropertyType}), remote.{remotePropertyName}.ToString() );");
                    }
                }
                else if (propertyMapping.IsNullable)
                {
                    if (propertyMapping.Type.IsASimpleType())
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = remote.{remotePropertyName}; }}");
                    }
                    else
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = { GetRemotePopulatorDTOMethodName(remotePropertyType)} (remote.{remotePropertyName}); }}");
                    }
                }
                else if (propertyMapping.IsDictionary)
                {
                    var dictLine = $"\tif (remote.{remotePropertyName} != null && remote.{remotePropertyName}.Any()) {{";

                    dictLine = dictLine + $"local.{localPropertyName} = remote.{remotePropertyName}.ToDictionary(";

                    foreach (var dictionaryType in propertyMapping.DictionaryTypes)
                    {
                        int index = propertyMapping.DictionaryTypes.IndexOf(dictionaryType);

                        if (dictionaryType.IsASimpleType())
                        {
                            dictLine = dictLine + $"pair=>";
                            if (index == 0)
                            {
                                dictLine = dictLine + $"pair.Key";
                            }
                            else
                            {
                                dictLine = dictLine + $"pair.Value";
                            }
                        }
                        else
                        {
                            dictLine = dictLine + $"pair=>";
                            if (index == 0)
                            {
                                dictLine = dictLine + $"{GetRemotePopulatorDTOMethodName(dictionaryType)}(pair.Key)";
                            }
                            else
                            {
                                dictLine = dictLine + $"{GetRemotePopulatorDTOMethodName(dictionaryType)}(pair.Value)";
                            }
                        }
                        dictLine = dictLine + $",";
                    }
                    if (dictLine.EndsWith(","))
                    {
                        dictLine = dictLine.Substring(0, dictLine.Length - 1);
                    }

                    dictLine = dictLine + " }";

                    builder.AppendLine(dictLine);
                }
                else if (propertyMapping.IsList)
                {
                    if (propertyMapping.Type.IsASimpleType())
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null && remote.{remotePropertyName}.Any()) {{ local.{localPropertyName} = remote.{remotePropertyName}.Select(r=> r ).ToList();  }} ");
                    }
                    else
                    {
                        var internalMapping = Singleton.Instance.MappingList.FirstOrDefault(r => r.Name == propertyMapping.Type);

                        if (internalMapping != null && internalMapping.IsAReference)
                        {
                            builder.AppendLine($"\tif (remote.{remotePropertyName} != null && remote.{remotePropertyName}.Any()) {{ local.{localPropertyName} = remote.{remotePropertyName}.Select(r=> {string.Format(Singleton.Instance.InputArgs.IsAReferenceTypeFormat, localPropertyType, Singleton.Instance.InputArgs.IsAReferenceTypeLookupKey)} ).ToList();  }} ");
                        }
                        else
                        {
                            builder.AppendLine($"\t if (remote.{remotePropertyName} != null && remote.{remotePropertyName}.Any()) {{ local.{localPropertyName} = remote.{remotePropertyName}.Select(r=> {GetRemotePopulatorDTOMethodName(remotePropertyType)}(r) ).ToList();  }} ");
                        }
                    }
                }
                else
                {
                    if (propertyMapping.Type.IsASimpleType())
                    {
                        builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = remote.{remotePropertyName}; }}");
                    }
                    else
                    {
                        var internalMapping = Singleton.Instance.MappingList.FirstOrDefault(r => r.Name == propertyMapping.Type);

                        if (internalMapping != null && internalMapping.IsAReference)
                        {
                            builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = {string.Format(Singleton.Instance.InputArgs.IsAReferenceTypeFormat, localPropertyType, Singleton.Instance.InputArgs.IsAReferenceTypeLookupKey)};  }}");
                        }
                        else
                        {
                            builder.AppendLine($"\tif (remote.{remotePropertyName} != null) {{ local.{localPropertyName} = {GetRemotePopulatorDTOMethodName(localPropertyType)} (remote.{remotePropertyName}); }}");
                        }
                    }
                }
            }

            builder.AppendLine("\treturn local;");

            builder.AppendLine("}");
            return(builder.ToString());
        }
        public GenreDTO Create(GenreDTO genre)
        {
            var result = _genreRepository.Create(Mapping.GenreFromBlToDal(genre));

            return(Mapping.GenreFromDalToBl(result));
        }
Example #48
0
        public override string BuildQueryString()
        {
            var properties = _entity.GetType().IsAnonymous() ? _entity.GetType().GetProperties() : this.Type.GetProperties().Where(o => !AvoidFields.Contains(o.Name));
            var keyFields  = KeyFieldCache.Instance.FindKeyFields(this.Type);

            this.Fields = properties.Where(o => !keyFields.Contains(o)).Concat(keyFields).Select(o => o.Name).ToList();

            //to do
            var hasGeometry = properties.Any(o => o.Name == this.GeometryQuery.GeometryField);

            if (hasGeometry)
            {
                //    for (int i = 0; i < parameterStrings.Length; i++)
                //    {
                //        if (parameterStrings[i] == "?G3E_GEOMETRY")
                //        {
                //            parameterStrings[i] = "GeomFromText(?G3E_GEOMETRY)";
                //        }
                //    }
            }
            //var conditionVisitor = new ConditionVisitor(this.Expr);
            //key field must be not update field

            //foreach (var propertyInfo in keyFields)
            //{
            //    this.Fields.Add(propertyInfo.Name);
            //}
            var condition = string.Join(" AND ", keyFields.Select(o => string.Format("{0}={1}{0}", o.Name, Seperator)).ToArray());

            return(string.Format("UPDATE {0} SET {1} WHERE {2} ", _byView? Mapping.GetUpdateView(Type.Name):Mapping.GetTableName(this.Type.Name),
                                 string.Join(",", properties.Where(o => !keyFields.Contains(o)).Select(o => string.Format("{0}={1}{0}", o.Name, Seperator)).ToArray()),
                                 condition));
        }
Example #49
0
 public virtual void Visit(Mapping mapping)
 {
     VisitSubNodes(mapping);
 }
        private void DeployFarmManagedProperty(object modelHost, FarmModelHost farmModelHost, ManagedPropertyDefinition definition)
        {
            farmModelHost.ShouldUpdateHost = false;

            ManagedPropertyCollection  properties;
            List <CrawledPropertyInfo> crawledProps;

            var existingProperty = GetCurrentObject(modelHost, definition, out properties, out crawledProps);

            var isNewMapping = existingProperty == null;

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioning,
                Object           = existingProperty,
                ObjectType       = typeof(ManagedProperty),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            if (existingProperty == null)
            {
                existingProperty = properties.Create(definition.Name, (ManagedDataType)Enum.Parse(typeof(ManagedDataType), definition.ManagedType));
            }

            existingProperty.Description = definition.Description ?? string.Empty;

            if (definition.Searchable.HasValue)
            {
                existingProperty.HasMultipleValues = definition.Searchable.Value;
            }

            if (definition.Queryable.HasValue)
            {
                existingProperty.Queryable = definition.Queryable.Value;
            }

            if (definition.Retrievable.HasValue)
            {
                existingProperty.Retrievable = definition.Retrievable.Value;
            }

            if (definition.HasMultipleValues.HasValue)
            {
                existingProperty.HasMultipleValues = definition.HasMultipleValues.Value;
            }

            if (definition.Refinable.HasValue)
            {
                existingProperty.Refinable = definition.Refinable.Value;
            }

            if (definition.Sortable.HasValue)
            {
                existingProperty.Sortable = definition.Sortable.Value;
            }

            if (definition.SafeForAnonymous.HasValue)
            {
                existingProperty.SafeForAnonymous = definition.SafeForAnonymous.Value;
            }

            if (definition.TokenNormalization.HasValue)
            {
                existingProperty.TokenNormalization = definition.TokenNormalization.Value;
            }


            //if (isNewMapping)
            //{
            var mappings = existingProperty.GetMappings();



            foreach (var managedPropertyMappping in definition.Mappings)
            {
                var crawledProp = crawledProps
                                  .FirstOrDefault(p => p.Name.ToUpper() == managedPropertyMappping.CrawledPropertyName.ToUpper());

                var mapping = new Mapping
                {
                    CrawledPropertyName = crawledProp.Name,
                    ManagedPid          = existingProperty.PID,
                };

                if (crawledProp != null)
                {
                    mapping.CrawledPropset = crawledProp.Propset;
                }

                mappings.Add(mapping);
            }

            existingProperty.SetMappings(mappings);
            //}

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model            = null,
                EventType        = ModelEventType.OnProvisioned,
                Object           = existingProperty,
                ObjectType       = typeof(ManagedProperty),
                ObjectDefinition = definition,
                ModelHost        = modelHost
            });

            // Write the changes back
            existingProperty.Update();
        }
 public CreatePortMappingRequestMessage(Mapping mapping)
 {
     _mapping = mapping;
 }
 protected virtual void FromEntityToViewModel(TSetting entity, TEV viewModel)
 {
     Mapping.Map(entity, viewModel);
 }
Example #53
0
        static int Main(string[] args)
        {
            var opt       = new Options();
            var optionset = new OptionSet()
            {
                { "m|mapping=", "the id of the mapping to generate code for", (int id) => opt.MappingId = id },
                { "u|user="******"your api-map user name", user => opt.UserName = user },
                { "p|password="******"your api-map user's password", pwd => opt.Password = pwd },
                { "o|output=", "output directory for generated code", outdir => opt.OutputDirectory = outdir },
            };

            List <string> extra;

            try
            {
                extra = optionset.Parse(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine($"Error: Unable to read options - {e.Message}");
                return(-1);
            }

            var errors = opt.Validate();

            if (errors.Any())
            {
                foreach (var error in errors)
                {
                    Console.WriteLine(error);
                }

                return(-1);
            }

            Mapping mapping = null;

            var gateway = new ApiMapGateway();

            try
            {
                var mappingTask = gateway.GetMapping(opt.MappingId.Value, new NetworkCredential(opt.UserName, opt.Password)); // why can't we 'await' here
                mappingTask.Wait();
                mapping = mappingTask.Result;
            }
            catch (AggregateException agEx)
            {
                foreach (var inner in agEx.InnerExceptions)
                {
                    Console.WriteLine($"Error: Unable to retrieve mapping - {inner.Message}");
                }
                return(-1);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: Unable to retrieve mapping - {ex.Message}");
                return(-1);
            }

            if (mapping == null)
            {
                Console.WriteLine($"Error: Unable to retrieve mapping {opt.MappingId}.");
                return(-1);
            }

            return(GenerateMappint(mapping, opt));
        }
 public CreatePortMappingMessage(Mapping mapping, IPAddress localIpAddress, UpnpNatRouterDevice device)
     : base(device, "AddPortMapping")
 {
     Mapping        = mapping;
     LocalIpAddress = localIpAddress;
 }
Example #55
0
 public string SerialiseMapping(Mapping mapping)
 {
     return(Serialise(writer => SerialiseMappingInternal(mapping, writer)));
 }
Example #56
0
    void MapPort()
    {
        try
        {
            Debug.Log("Mapping port...");

            udpMapping = new Mapping(Protocol.Udp, Port, Port)
            {
                Description = "Diluvium (UDP)"
            };
            natDevice.BeginCreatePortMap(udpMapping, state =>
            {
                if (state.IsCompleted)
                {
                    Debug.Log("UDP Mapping complete! Testing...");
                    try
                    {
                        var m = natDevice.GetSpecificMapping(Protocol.Udp, Port);
                        if (m == null)
                        {
                            throw new InvalidOperationException("Mapping not found");
                        }
                        if (m.PrivatePort != Port || m.PublicPort != Port)
                        {
                            throw new InvalidOperationException("Mapping invalid");
                        }

                        Debug.Log("Success!");
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("Failed to validate UDP mapping :\n" + ex.ToString());
                    }
                }
            }, null);

            tcpMapping = new Mapping(Protocol.Tcp, Port, Port)
            {
                Description = "Diluvium (TCP)"
            };
            natDevice.BeginCreatePortMap(tcpMapping, state =>
            {
                if (state.IsCompleted)
                {
                    Debug.Log("TCP Mapping complete! Testing...");
                    try
                    {
                        var m = natDevice.GetSpecificMapping(Protocol.Tcp, Port);
                        if (m == null)
                        {
                            throw new InvalidOperationException("Mapping not found");
                        }
                        if (m.PrivatePort != Port || m.PublicPort != Port)
                        {
                            throw new InvalidOperationException("Mapping invalid");
                        }

                        Debug.Log("Success!");
                    }
                    catch (Exception ex)
                    {
                        Debug.Log("Failed to validate TCP mapping :\n" + ex.ToString());
                    }
                }
            }, null);
        }
        catch (Exception ex)
        {
            Debug.Log("Failed to map port :\n" + ex.ToString());
        }
    }
Example #57
0
        public DS4Controls GetActiveInputControl(int ind)
        {
            DS4State        cState = CurrentState[ind];
            DS4StateExposed eState = ExposedState[ind];
            Mouse           tp     = touchPad[ind];
            DS4Controls     result = DS4Controls.None;

            if (DS4Controllers[ind] != null)
            {
                if (Mapping.getBoolButtonMapping(cState.Cross))
                {
                    result = DS4Controls.Cross;
                }
                else if (Mapping.getBoolButtonMapping(cState.Circle))
                {
                    result = DS4Controls.Circle;
                }
                else if (Mapping.getBoolButtonMapping(cState.Triangle))
                {
                    result = DS4Controls.Triangle;
                }
                else if (Mapping.getBoolButtonMapping(cState.Square))
                {
                    result = DS4Controls.Square;
                }
                else if (Mapping.getBoolButtonMapping(cState.L1))
                {
                    result = DS4Controls.L1;
                }
                else if (Mapping.getBoolTriggerMapping(cState.L2))
                {
                    result = DS4Controls.L2;
                }
                else if (Mapping.getBoolButtonMapping(cState.L3))
                {
                    result = DS4Controls.L3;
                }
                else if (Mapping.getBoolButtonMapping(cState.R1))
                {
                    result = DS4Controls.R1;
                }
                else if (Mapping.getBoolTriggerMapping(cState.R2))
                {
                    result = DS4Controls.R2;
                }
                else if (Mapping.getBoolButtonMapping(cState.R3))
                {
                    result = DS4Controls.R3;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadUp))
                {
                    result = DS4Controls.DpadUp;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadDown))
                {
                    result = DS4Controls.DpadDown;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadLeft))
                {
                    result = DS4Controls.DpadLeft;
                }
                else if (Mapping.getBoolButtonMapping(cState.DpadRight))
                {
                    result = DS4Controls.DpadRight;
                }
                else if (Mapping.getBoolButtonMapping(cState.Share))
                {
                    result = DS4Controls.Share;
                }
                else if (Mapping.getBoolButtonMapping(cState.Options))
                {
                    result = DS4Controls.Options;
                }
                else if (Mapping.getBoolButtonMapping(cState.PS))
                {
                    result = DS4Controls.PS;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, true))
                {
                    result = DS4Controls.LXPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LX, false))
                {
                    result = DS4Controls.LXNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, true))
                {
                    result = DS4Controls.LYPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.LY, false))
                {
                    result = DS4Controls.LYNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, true))
                {
                    result = DS4Controls.RXPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RX, false))
                {
                    result = DS4Controls.RXNeg;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, true))
                {
                    result = DS4Controls.RYPos;
                }
                else if (Mapping.getBoolAxisDirMapping(cState.RY, false))
                {
                    result = DS4Controls.RYNeg;
                }
                else if (Mapping.getBoolTouchMapping(tp.leftDown))
                {
                    result = DS4Controls.TouchLeft;
                }
                else if (Mapping.getBoolTouchMapping(tp.rightDown))
                {
                    result = DS4Controls.TouchRight;
                }
                else if (Mapping.getBoolTouchMapping(tp.multiDown))
                {
                    result = DS4Controls.TouchMulti;
                }
                else if (Mapping.getBoolTouchMapping(tp.upperDown))
                {
                    result = DS4Controls.TouchUpper;
                }
            }

            return(result);
        }
Example #58
0
 public void Setup()
 {
     Mapping.CreateConfiguration();
 }
Example #59
0
            /// <summary>
            /// Compares this Mapping to another object.
            /// </summary>
            /// <param name="obj">The other object.</param>
            /// <returns>True if the other object is a Mapping and equal to this one.</returns>
            public override bool Equals(object obj)
            {
                Mapping rhs = (Mapping)obj;

                return(_netType == rhs._netType && _bsonType == rhs._bsonType);
            }
Example #60
0
 public CSharpGenerator(TemplateParser templateParser, TextWriter textWriter, Mapping mapping, List <string> includedFiles)
     : base(templateParser)
 {
     this.TextRenderer  = new TextRenderer(textWriter, mapping);
     this.IncludedFiles = includedFiles;
 }