Esempio n. 1
0
 public void DefaultFoo()
 {
     string reqXml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>Foo</methodName>
       <params>
     <param>
       <value><string>1234</string></value>
     </param>
       </params>
     </methodCall>";
     Stream reqStm = new MemoryStream(ASCIIEncoding.Default.GetBytes(reqXml));
     XmlRpcServerProtocol svrProt = new DefaultService();
     Stream respStm = svrProt.Invoke(reqStm);
     StreamReader rdr = new StreamReader(respStm);
     string response = rdr.ReadToEnd();
     string respXml = @"<?xml version=""1.0""?>
     <methodResponse>
       <params>
     <param>
       <value>
     <string>1234</string>
       </value>
     </param>
       </params>
     </methodResponse>";
     Assert.AreEqual(respXml, response);
 }
        public string GetNameForResponseField(SdkMessageResponse response, SdkMessageResponseField responseField, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForResponseField(response, responseField, services);

            return(CamelCaseMemberNames
                ? CamelCaser.Case(defaultName)
                : defaultName);
        }
        public string GetNameForRelationship(EntityMetadata entityMetadata, RelationshipMetadataBase relationshipMetadata, EntityRole?reflexiveRole, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForRelationship(entityMetadata, relationshipMetadata, reflexiveRole, services);

            return(CamelCaseMemberNames
                ? CamelCaser.Case(defaultName)
                : defaultName);
        }
        public string GetNameForEntity(EntityMetadata entityMetadata, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForEntity(entityMetadata, services);

            return(CamelCaseClassNames
                ? CamelCaser.Case(defaultName)
                : defaultName);
        }
Esempio n. 5
0
 public bool GenerateRelationship(RelationshipMetadataBase relationshipMetadata, EntityMetadata otherEntityMetadata, IServiceProvider services)
 {
     if (!GenerateEntityRelationships)
     {
         return(false);
     }
     return(DefaultService.GenerateRelationship(relationshipMetadata, otherEntityMetadata, services));
 }
        /// <summary>
        /// Get the Delete client.
        /// </summary>
        /// <returns>the new client instance for Delete API</returns>
        public DeleteApi GetDeleteApi()
        {
            var service = new DefaultService((Configuration)_apiClient.Configuration)
            {
                ExceptionFactory = _exceptionFactory
            };

            return(new DeleteApi(service));
        }
Esempio n. 7
0
        public void RegisterTest()
        {
            var Code = ValidateCodeHelper.GetRandomCode(7);

            ValidateCodeHelper.SetCodeString(Code);
            Assert.IsTrue(DefaultService.Register(new ResultModel(), new Model.RegisterModel {
                Password = "******", RePassword = "******", Telephone = "123456", UserName = "******", VerisonCode = Code
            }));
        }
 /// <summary>
 /// Sets up HTTP methods mappings.
 /// </summary>
 /// <param name="service">Service handling requests</param>
 public DefaultModule(DefaultService service) : base("/v1alpha1")
 {
     Post["/test"] = parameters =>
     {
         var body = this.Bind <InlineObject>();
         service.TestPost(Context, body);
         return(new Response {
             ContentType = ""
         });
     };
 }
Esempio n. 9
0
 public BillsController()
 {
     billService     = new BillService();
     vendorService   = new VendorService();
     categoryService = new CategoryService();
     currencyService = new CurrencyService();
     itemService     = new ItemService();
     taxService      = new TaxService();
     defaultService  = new DefaultService();
     branchService   = new BranchService();
     emailService    = new EmailService();
 }
 public InvoicesController()
 {
     invoiceService  = new InvoiceService();
     currencyService = new CurrencyService();
     categoryService = new CategoryService();
     customerService = new CustomersService();
     itemService     = new ItemService();
     taxService      = new TaxService();
     defaultService  = new DefaultService();
     branchService   = new BranchService();
     emailService    = new EmailService();
 }
Esempio n. 11
0
 public bool GenerateOptionSet(OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
 {
     //if (optionSetMetadata.OptionSetType.Value == OptionSetType.State
     //        || optionSetMetadata.OptionSetType.Value == OptionSetType.Status
     //        || optionSetMetadata.OptionSetType.Value == OptionSetType.Picklist && optionSetMetadata.IsGlobal == false)
     //{
     //    return true;
     //}
     //else
     //{
     return(DefaultService.GenerateOptionSet(optionSetMetadata, services));
     // }
 }
Esempio n. 12
0
        public bool GenerateEntity(EntityMetadata entityMetadata, IServiceProvider services)
        {
            if (!DefaultService.GenerateEntity(entityMetadata, services))
            {
                return(false);
            }

            if (!EntityMetadata.ContainsKey(entityMetadata.LogicalName))
            {
                EntityMetadata.Add(entityMetadata.LogicalName, entityMetadata);
            }
            return(!EntitiesToSkip.Contains(entityMetadata.LogicalName));
        }
Esempio n. 13
0
        /// <summary>
        /// Sets up HTTP methods mappings.
        /// </summary>
        /// <param name="service">Service handling requests</param>
        public DefaultModule(DefaultService service) : base("/")
        {
            Post["/authenticate"] = parameters =>
            {
                var authenticationRequest = this.Bind <AuthenticationRequest>();
                Preconditions.IsNotNull(authenticationRequest, "Required parameter: 'authenticationRequest' is missing at 'Authenticate'");

                return(service.Authenticate(Context, authenticationRequest));
            };

            Post["/invalidate"] = parameters =>
            {
                var accessKeys = this.Bind <AccessKeys>();
                Preconditions.IsNotNull(accessKeys, "Required parameter: 'accessKeys' is missing at 'Invalidate'");

                service.Invalidate(Context, accessKeys);
                return(new Response {
                    ContentType = "application/json"
                });
            };

            Post["/refresh"] = parameters =>
            {
                var refreshRequest = this.Bind <RefreshRequest>();
                Preconditions.IsNotNull(refreshRequest, "Required parameter: 'refreshRequest' is missing at 'Refresh'");

                return(service.Refresh(Context, refreshRequest));
            };

            Post["/signout"] = parameters =>
            {
                var usernamePassword = this.Bind <UsernamePassword>();
                Preconditions.IsNotNull(usernamePassword, "Required parameter: 'usernamePassword' is missing at 'Siginout'");

                service.Siginout(Context, usernamePassword);
                return(new Response {
                    ContentType = "application/json"
                });
            };

            Post["/validate"] = parameters =>
            {
                var accessKeys = this.Bind <AccessKeys>();
                Preconditions.IsNotNull(accessKeys, "Required parameter: 'accessKeys' is missing at 'Validate'");

                service.Validate(Context, accessKeys);
                return(new Response {
                    ContentType = "application/json"
                });
            };
        }
Esempio n. 14
0
        private string GetPossiblyDuplicateNameForOption(OptionSetMetadataBase metadata, IServiceProvider services, OptionMetadata option)
        {
            var defaultName = DefaultService.GetNameForOption(metadata, option, services);

            defaultName = Transliterate(option, defaultName);

            var name = GetValidCSharpName(defaultName);

            if (defaultName == string.Empty)
            {
                name = name + option.Value;
            }
            return(name);
        }
Esempio n. 15
0
        public bool GenerateEntity(EntityMetadata entityMetadata, IServiceProvider services)
        {
            // Some entities are not normally create (attachment for example) not sure why.  Allowing Whitelist to Override here.
            if (!Approver.IsExplicitlyAllowed(entityMetadata.LogicalName) &&
                !DefaultService.GenerateEntity(entityMetadata, services))
            {
                return(false);
            }

            if (!EntityMetadata.ContainsKey(entityMetadata.LogicalName))
            {
                EntityMetadata.Add(entityMetadata.LogicalName, entityMetadata);
            }

            return(Approver.IsAllowed(entityMetadata.LogicalName));
        }
        /// <summary>
        /// Allows for Specified Attribute Nmaes to be used to set the generated attribute name
        /// </summary>
        /// <param name="entityMetadata">The entity metadata.</param>
        /// <param name="attributeMetadata">The attribute metadata.</param>
        /// <param name="services">The services.</param>
        /// <returns></returns>
        public string GetNameForAttribute(EntityMetadata entityMetadata, AttributeMetadata attributeMetadata, IServiceProvider services)
        {
            HashSet <string> specifiedNames;
            string           attributeName;

            if (EntityAttributeSpecifiedNames.TryGetValue(entityMetadata.LogicalName.ToLower(), out specifiedNames) &&
                specifiedNames.Any(s => string.Equals(s, attributeMetadata.LogicalName, StringComparison.OrdinalIgnoreCase)))
            {
                attributeName = specifiedNames.First(s => string.Equals(s, attributeMetadata.LogicalName, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                attributeName = DefaultService.GetNameForAttribute(entityMetadata, attributeMetadata, services);
            }
            return(attributeName);
        }
Esempio n. 17
0
        public void SystemMethodSignature()
        {
            var    reqXml = @"<?xml version=""1.0"" ?> 
<methodCall>
  <methodName>system.methodSignature</methodName> 
  <params>
    <param>
      <value>
        <string>Foo</string>
      </value>    
    </param>
  </params>
</methodCall>";
            Stream reqStm = new MemoryStream(Encoding.Default.GetBytes(reqXml));
            XmlRpcServerProtocol svrProt = new DefaultService();
            Stream respStm  = svrProt.Invoke(reqStm);
            var    rdr      = new StreamReader(respStm);
            var    response = rdr.ReadToEnd();
            var    respXml  = @"<?xml version=""1.0""?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <array>
                <data>
                  <value>
                    <string>string</string>
                  </value>
                  <value>
                    <string>string</string>
                  </value>
                </data>
              </array>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>";

            Assert.AreEqual(respXml, response);
        }
    void Start()
    {
        var bb = UBTContext.Instance.GetGlobalBlackboard("DefaultBB");

        bb.Set("energy", 10);
        bb.Set("sleep", false);

        var working = new Sequence().OpenBranch(
            new Wait(1f),
            new Actions(() => bb.Get <int>("energy").Value--),
            new Log("working")
            );

        var eating = new Sequence().OpenBranch(
            new Wait(1f),
            new Actions(() => bb.Get <int>("energy").Value++),
            new Log("eating")
            );

        var sleep = new Sequence().OpenBranch(
            new Wait(1f),
            new Log("sleep")
            );

        var sleepCondition  = new BlackboardCondition <bool>("sleep", Operator.IS_EQUAL, true, ObserverAborts.BOTH).Decorate(sleep);
        var eatingCondition = new BlackboardCondition <int>("energy", Operator.IS_SMALLER, 5, ObserverAborts.BOTH).Decorate(eating);

        var selector = new Selector().OpenBranch(
            sleepCondition,
            eatingCondition,
            working
            );

        var service = new DefaultService(UpdateStatus).Decorate(selector);

        m_Root = new Root(bb).Decorate(service);

#if UNITY_EDITOR
        UBTDebugger debugger = gameObject.AddComponent <UBTDebugger>();
        debugger.behaviorTree = m_Root;
#endif
        //m_Root.RepeatRoot = false;
        m_Root.Start();
    }
Esempio n. 19
0
        private string GetNameForAttribute(EntityMetadata entityMetadata, AttributeMetadata attributeMetadata, IServiceProvider services, bool camelCase)
        {
            string attributeName;

            if (EntityAttributeSpecifiedNames.TryGetValue(entityMetadata.LogicalName.ToLower(), out var specifiedNames) &&
                specifiedNames.Any(s => string.Equals(s, attributeMetadata.LogicalName, StringComparison.OrdinalIgnoreCase)))
            {
                attributeName = specifiedNames.First(s => string.Equals(s, attributeMetadata.LogicalName, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                attributeName = DefaultService.GetNameForAttribute(entityMetadata, attributeMetadata, services);
                attributeName = camelCase
                    ? CamelCaser.Case(attributeName)
                    : attributeName;
            }

            return(attributeName);
        }
        /// <summary>
        /// Provide a new implementation for finding a name for an OptionSet. If the
        /// OptionSet is not global, we want the name to be the concatenation of the Entity's
        /// name and the Attribute's name.  Otherwise, we can use the default implementation.
        /// </summary>
        public string GetNameForOptionSet(EntityMetadata entityMetadata, OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForOptionSet(entityMetadata, optionSetMetadata, services);

            if (EntityNames.Contains(defaultName))
            {
                throw new Exception($"{defaultName} already exists as an entity.  This will cause a naming collision.");
            }

            if (UseDeprecatedOptionSetNaming)
            {
                return(defaultName);
            }
            // Ensure that the OptionSet is not global before using the custom implementation.
            if (optionSetMetadata.IsGlobal.HasValue && !optionSetMetadata.IsGlobal.Value)
            {
                // Find the attribute which uses the specified OptionSet.
                var attribute =
                    (from a in entityMetadata.Attributes
                     where a.AttributeType == AttributeTypeCode.Picklist &&
                     ((EnumAttributeMetadata)a).OptionSet.MetadataId == optionSetMetadata.MetadataId
                     select a).FirstOrDefault();

                // Check for null, since statuscode attributes on custom entities are not global,
                // but their optionsets are not included in the attribute metadata of the entity, either.
                if (attribute == null)
                {
                    if (optionSetMetadata.OptionSetType.GetValueOrDefault() == OptionSetType.Status && defaultName.EndsWith("statuscode"))
                    {
                        defaultName = string.Format(LocalOptionSetFormat, GetNameForEntity(entityMetadata, services), "StatusCode");
                    }
                }
                else
                {
                    // Concatenate the name of the entity and the name of the attribute
                    // together to form the OptionSet name.
                    return(string.Format(LocalOptionSetFormat, GetNameForEntity(entityMetadata, services),
                                         GetNameForAttribute(entityMetadata, attribute, services, CamelCaseClassNames)));
                }
            }
            return(UpdateCasingForGlobalOptionSets(defaultName, optionSetMetadata));
        }
        public bool GenerateEntity(EntityMetadata entityMetadata, IServiceProvider services)
        {
            if (!DefaultService.GenerateEntity(entityMetadata, services))
            {
                return(false);
            }

            if (!EntityMetadata.ContainsKey(entityMetadata.LogicalName))
            {
                EntityMetadata.Add(entityMetadata.LogicalName, entityMetadata);
            }

            // If Whitelist is populated, Skip if not in Whitelist.
            if (EntitiesWhitelist.Count > 0 && !EntitiesWhitelist.Contains(entityMetadata.LogicalName))
            {
                return(false);
            }

            return(!EntitiesToSkip.Contains(entityMetadata.LogicalName) && !EntityPrefixesToSkip.Any(p => entityMetadata.LogicalName.StartsWith(p)));
        }
        private IOrganizationMetadata LoadMetadataInternal()
        {
            IOrganizationMetadata metadata;

            if (!File.Exists(RootPath(FilePath)) || !ReadSerializedMetadata)
            {
                metadata = DefaultService.LoadMetadata();

                if (SerializeMetadata)
                {
                    SerializeMetadataToFile(metadata, FilePath);
                }
            }
            else
            {
                metadata = DeserializeMetadata(FilePath);
            }

            return(metadata);
        }
        protected virtual IOrganizationMetadata LoadMetadataInternal()
        {
            IOrganizationMetadata metadata;

            if (ConfigHelper.GetAppSettingOrDefault("ReadSerializedMetadata", false))
            {
                metadata = DeserializeMetadata(FilePath);
            }
            else
            {
                metadata = DefaultService.LoadMetadata();

                if (ConfigHelper.GetAppSettingOrDefault("SerializeMetadata", false))
                {
                    SerializeMetadata(metadata, FilePath);
                }
            }

            return(metadata);
        }
        public string GetNameForOption(OptionSetMetadataBase optionSetMetadata, OptionMetadata optionMetadata, IServiceProvider services)
        {
            var defaultName = DefaultService.GetNameForOption(optionSetMetadata, optionMetadata, services);

            defaultName = Transliterate(optionMetadata, defaultName);

            var newName = GetValidCSharpName(defaultName);

            newName = AppendValueForDuplicateOptionSetValueNames(optionSetMetadata, newName, optionMetadata.Value.GetValueOrDefault(), services);

            if (newName == defaultName)
            {
                Trace.TraceInformation("The name of this option is {0}", defaultName);
            }
            else
            {
                Trace.TraceInformation("The name of this option was {0} but has been changed to {1}", defaultName, newName);
            }

            return(newName);
        }
        /// <summary>
        /// Checks to make sure that the name does not already exist for the OptionSetto be generated.
        /// </summary>
        private Dictionary <string, bool> GetDuplicateNameValues(OptionSetMetadataBase metadata, IServiceProvider services)
        {
            var nameValueDups = new Dictionary <string, bool>();

            // Look through all options, populating the namesAndValues Collection
            foreach (var option in metadata.GetOptions())
            {
                var defaultName = DefaultService.GetNameForOption(metadata, option, services);

                defaultName = Transliterate(option, defaultName);

                var name = GetValidCSharpName(defaultName);

                nameValueDups[name] = nameValueDups.ContainsKey(name);

                if (metadata.OptionSetType == OptionSetType.Status)
                {
                    // For Statuses, also do State
                    name = AppendState(option, name);
                    nameValueDups[name] = nameValueDups.ContainsKey(name);
                }
            }
            return(nameValueDups);
        }
Esempio n. 26
0
 public bool GenerateServiceContext(IServiceProvider services)
 {
     return(DefaultService.GenerateServiceContext(services));
 }
Esempio n. 27
0
 public bool GenerateOption(OptionMetadata optionMetadata, IServiceProvider services)
 {
     return(DefaultService.GenerateOption(optionMetadata, services));
 }
Esempio n. 28
0
 public bool GenerateAttribute(AttributeMetadata attributeMetadata, IServiceProvider services)
 {
     return(DefaultService.GenerateAttribute(attributeMetadata, services));
 }
Esempio n. 29
0
 public string GetNameForEntitySet(EntityMetadata entityMetadata, IServiceProvider services)
 {
     return(DefaultService.GetNameForEntitySet(entityMetadata, services));
 }
Esempio n. 30
0
 public string GetNameForMessagePair(SdkMessagePair messagePair, IServiceProvider services)
 {
     return(DefaultService.GetNameForMessagePair(messagePair, services));
 }
Esempio n. 31
0
 public bool GenerateOptionSet(OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
 {
     return(DefaultService.GenerateOptionSet(optionSetMetadata, services));
 }
        public void ProcessAsync_WhenTestList1_ExpectLoggingAndTimingOutput()
        {
            // arrange
            var mockConfiguration = new Mock<IConfiguration<KeyAuthentication>>();

            mockConfiguration.Setup(r => r.Get).Returns(() => new KeyAuthentication { LicenseKey = MyLicenseKey });

            var defaultClient = new DefaultClient(mockConfiguration.Object);

            var defaultService = new DefaultService(defaultClient);
            defaultService.ProgressChanged += (o, args) => Console.WriteLine(JsonConvert.SerializeObject(args));

            // act
            var stopwatch = Stopwatch.StartNew();
            var verificationResponses = defaultService.ProcessAsync(new VerificationRequest { Emails = TestList1 }, CancellationToken.None).Result;
            stopwatch.Stop();

            // assert
            Console.WriteLine("# emails checked: {0}", verificationResponses.Results.Count);
            Console.WriteLine(JsonConvert.SerializeObject(verificationResponses));
            WriteTimeElapsed(stopwatch.ElapsedMilliseconds);
        }