public Mock<IResearchItemRepository> GetResearchItemsRepository(ReturnType returnType)
        {
            var mockResearchItemRepository = new Mock<IResearchItemRepository>();

            var researchItemListJames = new List<ResearchItem>();
            researchItemListJames.Add(researchItems[0]);
            researchItemListJames.Add(researchItems[1]);

            var researchItemListJohn = new List<ResearchItem>();
            researchItemListJohn.Add(researchItems[2]);

            if (returnType == ReturnType.Exception)
            {
                mockResearchItemRepository.Setup(m => m.GetByUserAndProject(It.IsAny<string>(), It.IsAny<int>())).Throws(new ApplicationException("Database exception!"));
                mockResearchItemRepository.Setup(m => m.GetByUser(It.IsAny<int>(), It.IsAny<string>())).Throws(new ApplicationException("Database exception!"));
                mockResearchItemRepository.Setup(m => m.Insert(It.IsAny<ResearchItem>())).Throws(new ApplicationException("Database exception!"));
                mockResearchItemRepository.Setup(m => m.Delete(It.IsAny<ResearchItem>())).Throws(new ApplicationException("Database exception!"));
                mockResearchItemRepository.Setup(m => m.Commit()).Throws(new ApplicationException("Database exception!"));
            }
            else
            {
                mockResearchItemRepository.Setup(m => m.GetByUserAndProject("james",1)).Returns(researchItemListJames.AsQueryable());
                mockResearchItemRepository.Setup(m => m.GetByUserAndProject("john", 3)).Returns(researchItemListJohn.AsQueryable());
                mockResearchItemRepository.Setup(m => m.GetByUser(1, "james")).Returns(researchItems[0]);
                mockResearchItemRepository.Setup(m => m.GetByUser(1, "john")).Returns((ResearchItem)null);
                mockResearchItemRepository.Setup(m => m.Delete(It.IsAny<ResearchItem>()));
                mockResearchItemRepository.Setup(m => m.Insert(It.IsAny<ResearchItem>()));
                mockResearchItemRepository.Setup(m => m.Commit());
            }

            return mockResearchItemRepository;
        }
        public Mock<IProjectRepository> GetProjectsRepository(ReturnType returnType)
        {
            var mockProjectRepository = new Mock<IProjectRepository>();

            var projectListJames = new List<Project>();
            projectListJames.Add(projects[0]);
            projectListJames.Add(projects[1]);

            var projectListJohn = new List<Project>();
            projectListJohn.Add(projects[2]);

            if (returnType == ReturnType.Exception) {
                mockProjectRepository.Setup(m => m.GetByUser(It.IsAny<string>())).Throws(new ApplicationException("Database exception!"));
                mockProjectRepository.Setup(m => m.GetByUser(It.IsAny<int>(), It.IsAny<string>())).Throws(new ApplicationException("Database exception!"));
                mockProjectRepository.Setup(m => m.Insert(It.IsAny<Project>())).Throws(new ApplicationException("Database exception!"));
                mockProjectRepository.Setup(m => m.Delete(It.IsAny<Project>())).Throws(new ApplicationException("Database exception!"));
                mockProjectRepository.Setup(m => m.Commit()).Throws(new ApplicationException("Database exception!"));
            } else {
                mockProjectRepository.Setup(m => m.GetByUser("james")).Returns(projectListJames.AsQueryable());
                mockProjectRepository.Setup(m => m.GetByUser("john")).Returns(projectListJohn.AsQueryable());
                mockProjectRepository.Setup(m => m.GetByUser(1,"james")).Returns(projects[0]);
                mockProjectRepository.Setup(m => m.GetByUser(1, "john")).Returns((Project)null);
                mockProjectRepository.Setup(m => m.GetByUser(3, "john")).Returns(projects[2]);
                mockProjectRepository.Setup(m => m.Delete(It.IsAny<Project>()));
                mockProjectRepository.Setup(m => m.Insert(It.IsAny<Project>()));
                mockProjectRepository.Setup(m => m.Commit());
            }

            return mockProjectRepository;
        }
Example #3
0
        public static string GetMessage(ReturnType resultType)
        {
            string message = string.Empty;

            switch (resultType)
            {
                case ReturnType.OperationError:
                    message = "Operation Error";
                    break;

                case ReturnType.DispatcherError:
                    message = "Dispatcher Error";
                    break;

                case ReturnType.Success:
                    message = "Success";
                    break;

                case ReturnType.UnkownError:
                    message = "Unkown Error";
                    break;

                default:
                    message = "Unkown Error";
                    break;
            }

            return message;
        }
Example #4
0
 /// <summary>
 /// Creates an instance
 /// </summary>
 /// <param name="type">Returntype</param>
 /// <param name="arg">Arguments</param>
 /// <param name="metaData">MetaDatas</param>
 /// <param name="className">ClassName</param>
 /// <returns>New instance of MethodResult</returns>
 public static MethodResult CreateInstance(ReturnType type, object arg, IDictionary<string, string> metaData, string className)
 {
     MethodResult result = new MethodResult();
     result.type = type;
     result.arg = arg;
     result.metaData = metaData;
     result.className = className;
     return result;
 }
Example #5
0
        public string GetInvokeBlock(ReturnType returnType, string name, int parametersCount)
        {
            var sb = new StringBuilder();

            sb.Append(returnType == Model.ReturnType.Collection ? "VkResponseArray" : "VkResponse");
            sb.AppendFormat(" response = _vk.Call(\"{0}\", ", name);
            sb.Append(parametersCount > 0 ? "parameters);" : "VkParameters.Empty);");

            return sb.ToString();
        }
Example #6
0
 ReturnTypeUserControl GetUserControl(ReturnType r)
 {
     switch(r)
     {
         case ReturnType.Array: return new rtArray();
         case ReturnType.Bytes: return new rtBytes();
         case ReturnType.Dictionary: return new rtDictionary();
         case ReturnType.String: return new rtString();
     }
     return new ReturnTypeUserControl();
 }
        public ActiveDirectoryUser[] Search(string filterString, ReturnType type)
        {
            _Searcher.Filter = filterString;
            SearchResultCollection results = _Searcher.FindAll();
            if (type == ReturnType.Min)
                return ParseSubset(results);
            else if (type == ReturnType.Full)
                return ParseFull(results);

            return null;
        }
Example #8
0
        public static string ReturnTypeToString(ReturnType type)
        {
            Dictionary<ReturnType, string> dict = new Dictionary<ReturnType, string>();

            dict.Add(ReturnType.Void, "void");
            dict.Add(ReturnType.String, "string");
            dict.Add(ReturnType.Int, "int");
            dict.Add(ReturnType.Float, "float");
            dict.Add(ReturnType.Bool, "bool");

            return dict[type];
        }
Example #9
0
        //public HumanMacroData(Word.Range text, List<String> results)
        public HumanMacroData(Word.Range toShorten, int job, Separator separator, double reward, int redundancy, string title, string subtitle, string instructions, ReturnType type, TestOrReal test)
            : base(toShorten, job)
        {
            this.text = toShorten;
            this.separator = separator;
            //this.results = results;
            //patches = new List<HumanMacroPatch>();

            this.reward = reward;
            this.redundancy = redundancy;
            this.title = title;
            this.subtitle = subtitle;
            this.instructions = instructions;
            this.type = type;
            this.numberReturned = 0;
            this.test = test;

            //stages[HITData.ResultType.Macro] = new StageData(HITData.ResultType.Macro);
            macroStageData = new StageData(HITData.ResultType.Macro, job);
            stages.Add(macroStageData);
            //stages[HITData.ResultType.Macro] = new HumanMacroStage(HITData.ResultType.Macro, redundancy);

            results = new List<string>();
        }
Example #10
0
 public string GetReturnBlock(ReturnType returnType)
 {
     return string.Format("return response{0};",
         returnType == Model.ReturnType.Collection ? ".ToReadOnlyCollectionOf<>(x => x)" : string.Empty);
 }
Example #11
0
 public FrameworkException(string message, Exception innerException, ReturnType returnType)
     : this(message, innerException)
 {
     this.returnType = returnType;
 }
Example #12
0
 public static void ResponseOption(ResponseOption option, ReturnType returnType, bool returnComposedObjects)
 {
     Assert.AreEqual(returnType, option.ReturnType);
     Assert.AreEqual(returnComposedObjects, option.ReturnComposedObjects);
 }
Example #13
0
        public bool TryFoldInto(TSMemberDescription destination)
        {
            if (!ReturnType.Equals(destination.ReturnType))
            {
                return(false);
            }
            if (Parameters == null ^ destination.Parameters == null)
            {
                return(false);
            }                                                                          //one is a property, the other is not

            if (Parameters == null)
            {
                return(true);
            }

            var corresponding = Parameters.Zip(destination.Parameters).ToList();
            var equalTypes    = corresponding.All((sourceP, destP) => sourceP.Value.Type.Equals(destP.Value.Type));

            if (equalTypes)   //if there is only one additional parameter, we can fold using optional (or a rest) parameter
            {
                var allPairs = Parameters.ZipLongest(destination.Parameters, (sourceP, destP) => (sourceP: sourceP, destP: destP)).ToList();
                switch (allPairs.Count - corresponding.Count)
                {
                case 0:
                    return(true);

                case var x when x > 1:
                    return(false);

                case 1:
                    var extra = allPairs.Last();
                    var(sourceName, sourceDescr) = extra.sourceP;
                    var(destName, destDescr)     = extra.destP;
                    if (sourceName.IsNullOrEmpty())       //extra parameter in destination
                    {
                        if (destDescr.ParameterType == Standard)
                        {
                            destDescr.ParameterType = Optional;
                        }
                    }
                    else         //extra parameter in source
                    {
                        if (sourceDescr.ParameterType == Standard)
                        {
                            sourceDescr.ParameterType = Optional;
                        }
                        destination.Parameters.Add(sourceName, sourceDescr);
                    }
                    return(true);
                }
            }

            // TODO it might be possible to fold a method with one differing type, and a rest parameter.
            if (Parameters.Values().Any(x => x.ParameterType == Rest) || destination.Parameters.Values().Any(x => x.ParameterType == Rest))
            {
                return(false);
            }

            /*if (Parameters.Count != destination.Parameters.Count) {
             *  return false;
             * } else if (Parameters.Values().SequenceEqual(destination.Parameters.Values())) {
             *  return true;
             * }*/

            var foldableMethod       = true;
            var unfoldableParameters = Parameters.Values().Zip(destination.Parameters.Values(), (sourceParam, destParam) => {
                if (!foldableMethod)
                {
                    return(null);
                }
                if (sourceParam.ParameterType != destParam.ParameterType)   //if "optionality" of corresponding parameters doesn't match
                {
                    foldableMethod = false;
                    return(null);
                }
                var alreadyIncludesType = false;
                if (destParam.Type is TSComposedType x && sourceParam.Type is TSComposedType y)
                {
                    alreadyIncludesType = y.Parts.Except(x.Parts).None();
                }
Example #14
0
 /// <summary>
 /// Specify Xpath to find related Html Node.
 /// </summary>
 /// <param name="xpathString"></param>
 /// <param name="nodeReturnType">Specify you want the output include html text too.</param>
 public XPathAttribute(string xpathString, ReturnType nodeReturnType)
 {
     XPath          = xpathString;
     NodeReturnType = nodeReturnType;
 }
			public OrderedEnumerator(SequencedHashMap parent, ReturnType returnType)
			{
				_parent = parent;
				_returnType = returnType;
				_pos = _parent._sentinel;
				_expectedModCount = _parent._modCount;
			}
Example #16
0
 /// <summary>
 /// Sets the type of data that is expected to be returned from the request.
 /// 
 /// Defaults to Json.
 /// </summary>
 /// <param name="returnType">
 /// A <see cref="ReturnType"/>
 /// </param>
 /// <returns>
 /// A <see cref="Request"/>
 /// </returns>
 public IRequest Returning(ReturnType returnType)
 {
     ReturnType = returnType;
     return this;
 }
Example #17
0
 internal Enumerator(ImmutableTreeSet <KeyValuePair <TKey, TValue> > .Enumerator enumerator, ReturnType returnType)
 {
     _returnType = returnType;
     _enumerator = enumerator;
 }
Example #18
0
 /// <summary>
 /// Sets the Type of the Keyboard Return Key
 /// </summary>
 /// <param name="view">View.</param>
 /// <param name="value">Value.</param>
 public static void SetReturnType(BindableObject view, ReturnType value)
 {
     view.SetValue(ReturnTypeProperty, value);
 }
 public static void SetItemSource(BindableObject view, ReturnType value) => view.SetValue(ItemSourceProperty, value);
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (ApplicationName.Expression != null)
            {
                targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context));
            }

            if (BasePropertiesOnly.Expression != null)
            {
                targetCommand.AddParameter("BasePropertiesOnly", BasePropertiesOnly.Get(context));
            }

            if ((ComputerName.Expression != null) && (PSRemotingBehavior.Get(context) != RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", ComputerName.Get(context));
            }

            if (ConnectionURI.Expression != null)
            {
                targetCommand.AddParameter("ConnectionURI", ConnectionURI.Get(context));
            }

            if (Dialect.Expression != null)
            {
                targetCommand.AddParameter("Dialect", Dialect.Get(context));
            }

            if (Enumerate.Expression != null)
            {
                targetCommand.AddParameter("Enumerate", Enumerate.Get(context));
            }

            if (Filter.Expression != null)
            {
                targetCommand.AddParameter("Filter", Filter.Get(context));
            }

            if (Fragment.Expression != null)
            {
                targetCommand.AddParameter("Fragment", Fragment.Get(context));
            }

            if (OptionSet.Expression != null)
            {
                targetCommand.AddParameter("OptionSet", OptionSet.Get(context));
            }

            if (Port.Expression != null)
            {
                targetCommand.AddParameter("Port", Port.Get(context));
            }

            if (Associations.Expression != null)
            {
                targetCommand.AddParameter("Associations", Associations.Get(context));
            }

            if (ResourceURI.Expression != null)
            {
                targetCommand.AddParameter("ResourceURI", ResourceURI.Get(context));
            }

            if (ReturnType.Expression != null)
            {
                targetCommand.AddParameter("ReturnType", ReturnType.Get(context));
            }

            if (SelectorSet.Expression != null)
            {
                targetCommand.AddParameter("SelectorSet", SelectorSet.Get(context));
            }

            if (SessionOption.Expression != null)
            {
                targetCommand.AddParameter("SessionOption", SessionOption.Get(context));
            }

            if (Shallow.Expression != null)
            {
                targetCommand.AddParameter("Shallow", Shallow.Get(context));
            }

            if (UseSSL.Expression != null)
            {
                targetCommand.AddParameter("UseSSL", UseSSL.Get(context));
            }

            if (Credential.Expression != null)
            {
                targetCommand.AddParameter("Credential", Credential.Get(context));
            }

            if (Authentication.Expression != null)
            {
                targetCommand.AddParameter("Authentication", Authentication.Get(context));
            }

            if (CertificateThumbprint.Expression != null)
            {
                targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context));
            }

            if (GetIsComputerNameSpecified(context) && (PSRemotingBehavior.Get(context) == RemotingBehavior.Custom))
            {
                targetCommand.AddParameter("ComputerName", PSComputerName.Get(context));
            }

            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Example #21
0
 internal sealed override DiagnosticInfo GetUseSiteDiagnostic()
 {
     return(ReturnType.GetUseSiteDiagnostic());
 }
 public override bool Equals(object?obj) => obj is AccessExpression expression && EqualityComparer <IExpression> .Default.Equals(Accessee, expression.Accessee) && AccessOperator == expression.AccessOperator && EqualityComparer <Positioned <string> > .Default.Equals(Accessor, expression.Accessor) && Flags == expression.Flags && EqualityComparer <ITypeInfo> .Default.Equals(ReturnType, expression.ReturnType);
Example #23
0
 internal override ReturnType GetValueType(ReturnType returnType)
 {
     return(ReturnType.Integer);
 }
Example #24
0
 public IRequest Returning(ReturnType returnType)
 {
     ReturnType = returnType;
     return(this);
 }
Example #25
0
        public static bool Find(byte[] data, Byte[] pattern, out List <long> offsetsFound, long optionalOffsetResult = 0, bool optionalAbsoluteResult = false, long moduleBase = 0L, ReturnType returnType = ReturnType.ADDRESS)
        {
            int HARD_CAP_RESULT_AMOUNT = 25;
            var offsetsFoundInternal   = new List <long>();

            if (data == null || pattern == null)
            {
                offsetsFound = null;
                return(false);
            }

            var patternSize = pattern.LongLength;

            if (data.LongLength == 0 || patternSize == 0)
            {
                offsetsFound = null;
                return(false);
            }


            for (long i = 0, pos = 0; i < data.LongLength; i++)
            {
                if (matchByte(data[i], ref pattern[pos]))                 //check if the current data byte matches the current pattern byte
                {
                    pos++;
                    if (pos != patternSize)
                    {
                        continue;
                    }
                    var internalOffsetFound = i - patternSize + 1;
                    if (optionalAbsoluteResult)
                    {
                        internalOffsetFound += moduleBase;
                    }

                    if (optionalOffsetResult != 0)
                    {
                        internalOffsetFound += optionalOffsetResult;
                    }
                    switch (returnType)
                    {
                    case ReturnType.ADDRESS:
                        offsetsFoundInternal.Add(internalOffsetFound);
                        break;

                    case ReturnType.READ4BYTES:
                        byte[] byteSequence4 = MiniMem.ReadBytes(optionalAbsoluteResult ? internalOffsetFound : moduleBase + internalOffsetFound, 4);
                        offsetsFoundInternal.Add((long)BitConverter.ToInt32(byteSequence4, 0));
                        break;

                    case ReturnType.READ8BYTES:
                        byte[] byteSequence9 = MiniMem.ReadBytes(optionalAbsoluteResult ? internalOffsetFound : moduleBase + internalOffsetFound, 8);
                        offsetsFoundInternal.Add(BitConverter.ToInt64(byteSequence9, 0));
                        break;
                    }
                    pos = 0;
                    if (offsetsFoundInternal.Count >= HARD_CAP_RESULT_AMOUNT)
                    {
                        Debug.WriteLine($"Hard cap of {HARD_CAP_RESULT_AMOUNT} addresses have been hit so far with {data.LongLength - i} bytes left unread in buffer, stopping procedure ...");
                        break;
                    }
                }
                else
                {
                    i  -= pos;
                    pos = 0;                     //reset current pattern position
                }
            }

            offsetsFound = offsetsFoundInternal;
            return(offsetsFound.Count > 0);
            //return false;
        }
Example #26
0
 public override bool Equals(object obj)
 {
     return(obj is CFunctionType o && ReturnType.Equals(o.ReturnType) && ParameterTypesEqual(o));
 }
Example #27
0
 public static Mozu.Api.Contracts.CommerceRuntime.Returns.Return GenerateReturn(ReturnType returnType,
     List<Mozu.Api.Contracts.CommerceRuntime.Returns.ReturnItem> items,
     string originalOrderId, string returnOrderId, List<Mozu.Api.Contracts.CommerceRuntime.Orders.OrderNote> orderNote,
     List<Mozu.Api.Contracts.CommerceRuntime.Payments.Payment> payments,
     decimal? refundAmount,
     int? returnNumber,
     decimal totalLossAmount = 0)
 {
     return new Mozu.Api.Contracts.CommerceRuntime.Returns.Return
     {
         Items = items,
         OriginalOrderId = originalOrderId,
         ReturnOrderId = returnOrderId,
         Notes = orderNote,
         Payments = payments,
         RefundAmount = refundAmount,
         ReturnNumber = returnNumber,
         ReturnType = returnType.ToString(),
         //TotalLossAmount = totalLossAmount
     };
 }
 internal Enumerator(SegmentedDictionary <TKey, TValue> dictionary, ReturnType returnType)
 {
     _dictionary = dictionary;
     _returnType = returnType;
     _enumerator = dictionary.GetEnumerator();
 }
Example #29
0
 public ServerException(string message, Exception innerException, ReturnType errorType)
     : this(message, innerException)
 {
     this.errorType = errorType;
 }
Example #30
0
        /// <inheritdoc />
        public override string ToString()
        {
            var builder = new StringBuilder();

            if (Visibility != CppVisibility.Default)
            {
                builder.Append(Visibility.ToString().ToLowerInvariant());
                builder.Append(" ");
            }

            if (StorageQualifier != CppStorageQualifier.None)
            {
                builder.Append(StorageQualifier.ToString().ToLowerInvariant());
                builder.Append(" ");
            }

            if ((Flags & CppFunctionFlags.Virtual) != 0)
            {
                builder.Append("virtual ");
            }

            if (!IsConstructor)
            {
                if (ReturnType != null)
                {
                    builder.Append(ReturnType.GetDisplayName());
                    builder.Append(" ");
                }
                else
                {
                    builder.Append("void ");
                }
            }

            builder.Append(Name);
            builder.Append("(");
            for (var i = 0; i < Parameters.Count; i++)
            {
                var param = Parameters[i];
                if (i > 0)
                {
                    builder.Append(", ");
                }
                builder.Append(param);
            }

            if ((Flags & CppFunctionFlags.Variadic) != 0)
            {
                builder.Append(", ...");
            }

            builder.Append(")");

            if ((Flags & CppFunctionFlags.Const) != 0)
            {
                builder.Append(" const");
            }

            if ((Flags & CppFunctionFlags.Pure) != 0)
            {
                builder.Append(" = 0");
            }
            return(builder.ToString());
        }
Example #31
0
        public void CheckThatFactoryReturnsCorrectObject(ReturnType returnType)
        {
            IFactoryReturn factoryReturn = Factory.GetFactoryReturnObject(returnType);

            Assert.True(factoryReturn.GetValue() != null);
        }
Example #32
0
 public XPathAttribute(string xpathString, ReturnType nodeReturnType = ReturnType.InnerText)
 {
     XPath          = xpathString;
     NodeReturnType = nodeReturnType;
 }
Example #33
0
 public IEnumerable <TSSimpleType> TypeParts() => Parameters.DefaultIfNull().Values().SelectMany(x => x.Type.TypeParts()).Concat(ReturnType.TypeParts());
Example #34
0
 public QueryContext CreateQueryContext(ReturnType rt, EvaluationType et)
 {
     return QueryContext.Create(this.mgr_.createQueryContext(QueryContext.ReturnTypeToInt(rt), QueryContext.EvaluationTypeToInt(et)));
 }
Example #35
0
 public FrameworkException(string message, ReturnType returnType)
     : this(message)
 {
     this.returnType = returnType;
 }
Example #36
0
 public HsScriptsBlock(BinaryReader binaryReader)
 {
     this.name = binaryReader.ReadString32();
     this.scriptType = (ScriptType)binaryReader.ReadInt16();
     this.returnType = (ReturnType)binaryReader.ReadInt16();
     this.rootExpressionIndex = binaryReader.ReadInt32();
 }
Example #37
0
 public ReflectionException(string message, Exception innerException, ReturnType returnCode)
     : base(message, innerException, returnCode)
 {
 }
        /// <summary>
        /// Validates that the given parameter is a valid return type to make this
        /// condition list work properly
        /// </summary>
        /// <param name="ParamId">The current parameter index</param>
        /// <param name="RType">The return type if the current parameter</param>
        protected bool ValidateParam(int ParamId, ReturnType RType)
        {
            switch (Type)
            {
                case ConditionType.And:
                case ConditionType.Or:
                case ConditionType.Not:
                    return (RType == ReturnType.Bool);
                case ConditionType.Plus:
                case ConditionType.Div:
                    return (RType == ReturnType.Number);
            }

            return true;
        }
 public override int GetHashCode()
 {
     unchecked {
         var parametersHash = Parameters.Aggregate(0, (x, y) => x.GetHashCode() ^ y.GetHashCode());
         return(((Name != null ? Name.GetHashCode() : 0) * 397) ^ (ReturnType != null ? ReturnType.GetHashCode() : 0) ^ parametersHash);
     }
 }
Example #40
0
 public ReportParameterRelEPs(CamposRelEPs campo, string[] dbField, string[] joinClause, string[] whereClause, ReturnType rType)
     : base(dbField, joinClause, whereClause, rType)
 {
     this.campo = campo;
 }
 internal void CallOnReturn(ReturnType returnType)
 {
     onReturn.Callback(new ReturnParameter(returnType));
     onReturn = null;
 }
 private bool IsFunctionAsync()
 => ReturnType == "Task" || ReturnType.StartsWith("Task<");
Example #43
0
 public QueryContext CreateQueryContext(ReturnType rt)
 {
     return this.CreateQueryContext(rt, EvaluationType.Eager);
 }
Example #44
0
 public override String ToString()
 {
     return(ReturnType.FormatTypeName() + " " + FormatNameAndSig(false));
 }
        public override object GetSingleLog( LogInfo objLogInfo, ReturnType objReturnType )
        {
            XmlDocument xmlConfigDoc = GetConfigDoc();

            string strFileName = GetLogFileByLogFileID( GetConfigDoc(), objLogInfo.LogFileID );

            XmlDocument xmlDoc = new XmlDocument();
            int intAttempts = 0;
            //wait for up to 100 milliseconds for the file
            //to be unlocked if it is not available
            while( !( xmlDoc.OuterXml != "" || intAttempts == 100 ) )
            {
                intAttempts++;
                try
                {
                    xmlDoc.Load( strFileName );
                }
                catch( IOException )
                {
                    Thread.Sleep( 1 );
                }
            }

            XmlNode objxmlNode;
            objxmlNode = xmlDoc.SelectSingleNode( "/logs/log[@LogGUID='" + objLogInfo.LogGUID + "']" );

            XmlDocument xmlDocOut = new XmlDocument();
            xmlDocOut.LoadXml( "<SingleLog></SingleLog>" );
            XmlNode xmlNewNode;
            xmlNewNode = xmlDocOut.ImportNode( objxmlNode, true );
            xmlDocOut.DocumentElement.AppendChild( xmlNewNode );

            if( objReturnType == ReturnType.XML )
            {
                return xmlDocOut.DocumentElement.SelectSingleNode( "log" );
            }
            else
            {
                int records = 0;
                return GetLogInfoFromXML( xmlDocOut, int.MaxValue, 1, ref records ).GetItem( 0 );
            }
        }
Example #46
0
 internal string SerializationToString()
 {
     return(ReturnType.FormatTypeName(true) + " " + FormatNameAndSig(true));
 }
Example #47
0
        /// <summary>
        /// 操作数据
        /// </summary>
        /// <param name="parameter">短路径操作参数</param>
        /// <param name="onOperation"></param>
        internal void Operation(ref OperationParameter.ShortPathOperationNode parameter, AutoCSer.Net.TcpServer.ServerCallback <ReturnParameter> onOperation)
        {
            ReturnType returnType = ReturnType.CanNotWrite;

            try
            {
                if (CanWrite)
                {
                    if (parameter.Buffer != null)
                    {
                        returnType = ReturnType.NotFoundShortPath;
                        if (parameter.Identity.Ticks == startTicks)
                        {
                            byte[]           packet;
                            Cache.Value.Node node = shortPaths[parameter.Identity.Index].Get(parameter.Identity.Identity, out packet);
                            if (packet.Length == parameter.Identity.PacketSize)
                            {
                                if (node.IsNode)
                                {
                                    returnType = ReturnType.Unknown;
                                    byte[] bufferData = parameter.Buffer.Array.Array;
                                    System.Buffer.BlockCopy(packet, 0, bufferData, parameter.Buffer.Array.Start + OperationParameter.Serializer.HeaderSize, parameter.Identity.PacketSize);
                                    fixed(byte *bufferFixed = bufferData)
                                    {
                                        OperationParameter.NodeParser parser = new OperationParameter.NodeParser(this, parameter.Buffer, bufferFixed);
                                        parser.Read    += parameter.Identity.PacketSize;
                                        parser.OnReturn = onOperation;
                                        try
                                        {
                                            node.Operation(ref parser);
                                        }
                                        finally
                                        {
                                            if (parser.OnReturn == null)
                                            {
                                                returnType = ReturnType.Success;
                                            }
                                        }
                                        if (parser.IsOperation)
                                        {
                                            this.onOperation(parameter.Buffer);
                                        }
                                        else
                                        {
                                            parameter.Buffer.FreeReference();
                                        }
                                        return;
                                    }
                                }
                                else
                                {
                                    returnType = ReturnType.NotFoundShortPathNode;
                                }
                            }
                        }
                    }
                    else
                    {
                        returnType = ReturnType.ServerDeSerializeError;
                    }
                }
                parameter.Buffer.FreeReference();
            }
            finally
            {
                if (returnType != ReturnType.Success)
                {
                    onOperation.Callback(new ReturnParameter(returnType));
                }
            }
        }
Example #48
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="queryData">查询数据</param>
        /// <returns>返回参数</returns>
        internal ValueData.Data ShortPathQuery(ref SubArray <byte> queryData)
        {
            byte[]     data       = queryData.Array;
            ReturnType returnType = ReturnType.NotFoundShortPath;

            fixed(byte *dataFixed = queryData.Array)
            {
                byte *            start    = dataFixed + queryData.Start;
                ShortPathIdentity identity = new ShortPathIdentity(start + OperationParameter.Serializer.HeaderSize);

                if (identity.Ticks == startTicks)
                {
                    byte[]           packet;
                    Cache.Value.Node node = shortPaths[identity.Index].Get(identity.Identity, out packet);
                    if (packet.Length == identity.PacketSize)
                    {
                        if (node.IsNode)
                        {
                            returnType = ReturnType.Unknown;
                            if ((*(int *)start = queryData.Length + identity.PacketSize - ShortPathIdentity.SerializeSize) <= queryData.Length)
                            {
                                System.Buffer.BlockCopy(packet, 0, data, queryData.Start + OperationParameter.Serializer.HeaderSize, identity.PacketSize);
                                System.Buffer.BlockCopy(data, queryData.Start + (OperationParameter.Serializer.HeaderSize + ShortPathIdentity.SerializeSize), data, queryData.Start + (OperationParameter.Serializer.HeaderSize + identity.PacketSize), queryData.Length - (OperationParameter.Serializer.HeaderSize + ShortPathIdentity.SerializeSize));
                                queryData.Length = *(int *)start;

                                queryBuffer.Set(ref queryData);
                                OperationParameter.NodeParser parser = new OperationParameter.NodeParser(this, queryBuffer, dataFixed);
                                parser.Read += identity.PacketSize;
                                node.Query(ref parser);
                                return(parser.ReturnParameter);
                            }
                            else
                            {
                                Buffer buffer = BufferCount.GetBuffer(*(int *)start);
                                try
                                {
                                    SubArray <byte> bufferSubArray = buffer.Array;
                                    byte[]          bufferData     = bufferSubArray.Array;
                                    fixed(byte *bufferFixed = bufferData)
                                    {
                                        *(ulong *)(bufferFixed + bufferSubArray.Start) = *(ulong *)start;
                                        System.Buffer.BlockCopy(packet, 0, bufferData, bufferSubArray.Start + OperationParameter.Serializer.HeaderSize, identity.PacketSize);
                                        System.Buffer.BlockCopy(data, queryData.Start + (OperationParameter.Serializer.HeaderSize + ShortPathIdentity.SerializeSize), bufferData, bufferSubArray.Start + (OperationParameter.Serializer.HeaderSize + identity.PacketSize), queryData.Length - (OperationParameter.Serializer.HeaderSize + ShortPathIdentity.SerializeSize));

                                        OperationParameter.NodeParser parser = new OperationParameter.NodeParser(this, buffer, bufferFixed);
                                        parser.Read += identity.PacketSize;
                                        node.Query(ref parser);
                                        return(parser.ReturnParameter);
                                    }
                                }
                                finally { buffer.Dispose(); }
                            }
                        }
                        else
                        {
                            returnType = ReturnType.NotFoundShortPathNode;
                        }
                    }
                }
            }

            return(new ValueData.Data(returnType));
        }
Example #49
0
 protected ReportParameter(string[] dbField, string[] joinClause, string[] whereClause, ReturnType rType)
 {
     this.dbField = dbField;
     this.joinClause = joinClause;
     this.whereClause = whereClause;
     this.rType = rType;
 }
Example #50
0
        public override void OnCodeGenVisit(AssemblyGenerator assembler)
        {
            Right.OnCodeGenVisit(assembler);
            //assembler.EmitCode($"\tmovl %eax,%edx");
            assembler.EmitCode($"\tpushl %eax");
            Left.OnCodeGenVisit(assembler);
            assembler.EmitCode($"\tpopl %edx");
            ReturnType leftType = Left.GetReturnType(), rightType = Right.GetReturnType();
            string     postfix = "", regA = "", regB = "";

            switch (Cast(leftType, rightType))
            {
            case ReturnType.Char:
                postfix = "b";
                regA    = "%al";
                regB    = "%dl";
                Return  = ReturnType.Char;
                break;

            case ReturnType.Float:
                postfix = "l";
                regA    = "%eax";
                regB    = "%edx";
                Return  = ReturnType.Float;
                break;

            case ReturnType.Int:
                postfix = "l";
                regA    = "%eax";
                regB    = "%edx";
                Return  = ReturnType.Int;
                break;
            }
            switch (this.Operator)
            {
            case BinaryOperator.Plus:
                assembler.EmitCode($"\tadd{postfix} {regB},{regA}");
                break;

            case BinaryOperator.Minus:
                assembler.EmitCode($"\tsub{postfix} {regB},{regA}");
                break;

            case BinaryOperator.Multiply:
                assembler.EmitCode($"\timul{postfix} {regB},{regA}");
                break;

            case BinaryOperator.Divide:
                assembler.EmitCode($"\tpushl %edx");
                assembler.EmitCode($"\tcltd");
                assembler.EmitCode($"\tidivl (%esp)");
                assembler.EmitCode($"\taddl $4,%esp");
                break;

            case BinaryOperator.And:
                assembler.EmitCode($"\tcmp{postfix} $0,{regB}");
                assembler.EmitCode($"\tjz LGF{LogicCount}");
                assembler.EmitCode($"\tcmp{postfix} $0,{regA}");
                assembler.EmitCode($"\tjz LGF{LogicCount}");
                assembler.EmitCode($"\tmovl $1,%eax");
                assembler.EmitCode($"\tjmp LGE{LogicCount}");
                assembler.EmitCode($"LGF{LogicCount}:");
                assembler.EmitCode($"\tmovl $0,%eax");
                assembler.EmitCode($"LGE{LogicCount}:");
                LogicCount++;
                break;

            case BinaryOperator.Or:
                assembler.EmitCode($"\tcmp{postfix} $0,{regB}");
                assembler.EmitCode($"\tjnz LGT{LogicCount}");
                assembler.EmitCode($"\tcmp{postfix} $0,{regA}");
                assembler.EmitCode($"\tjnz LGT{LogicCount}");
                assembler.EmitCode($"\tmovl $0,%eax");
                assembler.EmitCode($"\tjmp LGE{LogicCount}");
                assembler.EmitCode($"LGT{LogicCount}:");
                assembler.EmitCode($"\tmovl $1,%eax");
                assembler.EmitCode($"LGE{LogicCount}:");
                LogicCount++;
                break;

            case BinaryOperator.Equal:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsete %al");
                assembler.EmitCode($"\tmovzbl %al,%eax");
                break;

            case BinaryOperator.GreaterEqual:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsetge %al");
                if (postfix == "l")
                {
                    assembler.EmitCode($"\tmovzbl %al,%eax");
                }
                break;

            case BinaryOperator.GreaterThan:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsetg %al");
                if (postfix == "l")
                {
                    assembler.EmitCode($"\tmovzbl %al,%eax");
                }
                break;

            case BinaryOperator.LessEqual:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsetle %al");
                if (postfix == "l")
                {
                    assembler.EmitCode($"\tmovzbl %al,%eax");
                }
                break;

            case BinaryOperator.LessThan:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsetl %al");
                if (postfix == "l")
                {
                    assembler.EmitCode($"\tmovzbl %al,%eax");
                }
                break;

            case BinaryOperator.NotEqual:
                assembler.EmitCode($"\tcmp{postfix} {regB},{regA}");
                assembler.EmitCode($"\tsetne %al");
                if (postfix == "l")
                {
                    assembler.EmitCode($"\tmovzbl %al,%eax");
                }
                break;
            }
        }
Example #51
0
 public override object GetSingleLog(LogInfo logInfo, ReturnType returnType)
 {
     IDataReader dr = DataProvider.Instance().GetSingleLog(logInfo.LogGUID);
     LogInfo log = null;
     try
     {
         if (dr != null)
         {
             dr.Read();
             log = FillLogInfo(dr);
         }
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     if (returnType == ReturnType.LogInfoObjects)
     {
         return log;
     }
     var xmlDoc = new XmlDocument();
     if (log != null)
     {
         xmlDoc.LoadXml(log.Serialize());
     }
     return xmlDoc.DocumentElement;
 }
Example #52
0
        protected override string InnerTranslate()
        {
            if (this.Syntax?.Identifier.ToString() == "GetDebuggerDisplay")
            {
                return("");
            }

            if (SemicolonToken == null || SemicolonToken.IsEmpty)
            {
                return(string.Format(@"{0} {1} {2}: {3}
{4}",
                                     Modifiers.Translate(),
                                     Identifier.Translate() + TypeParameterList?.Translate() ?? "",
                                     ParameterList.Translate(),
                                     ReturnType.Translate(),
                                     Body?.Translate() ?? ";"));
            }

            string appendStr = ";";
            var    found     = (TypeDeclarationTranslation)TravelUpNotMe(f => f is TypeDeclarationTranslation);

            if (found is ClassDeclarationTranslation && found.Modifiers.IsAbstract && !this.IsOverloadedDeclaration)
            {
                appendStr = "{ throw new Error('not implemented'); }";
            }

            return($@"{GetAttributeList()}{Modifiers.Translate()} {Identifier.Translate()}{TypeParameterList?.Translate() ?? ""} {ParameterList.Translate()} : {ReturnType.Translate()}{appendStr} ");
        }
Example #53
0
 private static string GetReturnMimeType(ReturnType returnType)
 {
     switch (returnType)
     {
         case ReturnType.Atom:
             return "application/atom+xml";
         case ReturnType.Json:
             return "application/json";
         default:
             throw new ArgumentOutOfRangeException("returnType", "Unknown Return-type: " + returnType);
     }
 }
Example #54
0
 public abstract object GetSingleLog(LogInfo LogInfo, ReturnType objReturnType);
Example #55
0
 public static Mozu.Api.Contracts.CommerceRuntime.Returns.Return GenerateReturn(ReturnType returnType,
     List<Mozu.Api.Contracts.CommerceRuntime.Returns.ReturnItem> items, string orderId)
 {
     return new Mozu.Api.Contracts.CommerceRuntime.Returns.Return
     {
         Items = items,
         OriginalOrderId = orderId,
         ReturnType = returnType.ToString()
     };
 }
Example #56
0
 internal abstract ReturnType GetValueType(ReturnType returnType);
 // methods to get the log entries
 public abstract object GetSingleLog(LogInfo LogInfo, ReturnType objReturnType);
Example #58
0
 internal override ReturnType GetValueType(ReturnType returnType)
 {
     return(returnType == ReturnType.Integer ? ReturnType.Real : returnType);
 }
Example #59
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Nosson.Core.ServerException"/> class.
 /// </summary>
 /// <param name="info">
 /// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
 /// that holds the serialized object data about the exception being thrown.
 /// </param>
 /// <param name="context">
 /// The <see cref="System.Runtime.Serialization.StreamingContext"/>
 /// that contains contextual information about the source or destination.
 /// </param>
 protected ServerException(
     SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     errorType = (ReturnType)info.GetValue("ErrorType", typeof(ReturnType));
 }
Example #60
0
 public bool Equals(MethodData?other) => other != null && Name == other.Name && ReturnType.Equals(other.ReturnType) && Parameters.Count == other.Parameters.Count && Parameters.Select((p, i) => (p, i)).All(t => t.p.Equals(other.Parameters[t.i]));