internal Response(ReturnCode result, int? ecadId, string geoDirectoryId, Request input, Model.Link[] links) { if (links == null) throw new ArgumentNullException("links"); Result = result; EcadId = ecadId; GeoDirectoryId = geoDirectoryId; Input = input; var newLinks = new List<Model.Link>(); foreach (Model.Link link in links) { Model.Link newLink; switch (link.Rel) { case "self": newLink = new Model.MapId.Link(link.Rel, link.Href); break; default: newLink = link; break; } newLinks.Add(newLink); } Links = newLinks.ToArray(); }
/// <summary> /// Construct a Response object from the supplied byte array /// </summary> /// <param name="message">a byte array returned from a DNS server query</param> internal Response(byte[] message) { if (message == null) throw new ArgumentNullException("message"); // the bit flags are in bytes 2 and 3 byte flags1 = message[2]; byte flags2 = message[3]; // get return code from lowest 4 bits of byte 3 int returnCode = flags2 & 15; // if its in the reserved section, set to other if (returnCode > 6) returnCode = 6; _returnCode = (ReturnCode) returnCode; // other bit flags _authoritativeAnswer = ((flags1 & 4) != 0); _recursionAvailable = ((flags2 & 128) != 0); _messageTruncated = ((flags1 & 2) != 0); // create the arrays of response objects _questions = new Question[GetShort(message, 4)]; _answers = new Answer[GetShort(message, 6)]; _nameServers = new NameServer[GetShort(message, 8)]; _additionalRecords = new AdditionalRecord[GetShort(message, 10)]; // need a pointer to do this, position just after the header var pointer = new Pointer(message, 12); ReadQuestions(pointer); ReadAnswers(pointer); ReadNameServers(pointer); ReadAdditionalRecords(pointer); }
internal Response(ReturnCode result, string postcode, SpatialInfo spatialInfo, Request input, Model.Link[] links) { if (links == null) throw new ArgumentNullException("links"); Result = result; Postcode = postcode; SpatialInfo = spatialInfo; Input = input; var newLinks = new List<Model.Link>(); foreach (Model.Link link in links) { Model.Link newLink; switch (link.Rel) { case "self": newLink = new Link(link.Rel, link.Href); break; default: newLink = link; break; } newLinks.Add(newLink); } Links = newLinks.ToArray(); }
internal Response(ReturnCode result, string postcode, int? addressId, AddressType? addressType, MatchLevel matchLevel, string[] postalAddress, AddressElement[] postalAddressElements, string[] geographicAddress, AddressElement[] geographicAddressElements, string[] vanityAddress, AddressElement[] vanityAddressElements, ReformattedAddressResult? reformattedAddressResult, string[] reformattedAddress, int totalOptions, Option[] options, Request input, Model.Link[] links ) { if (links == null) throw new ArgumentNullException("links"); Result = result; Postcode = postcode; AddressId = addressId; AddressType = addressType; MatchLevel = matchLevel; PostalAddress = postalAddress; PostalAddressElements = postalAddressElements; GeographicAddress = geographicAddress; GeographicAddressElements = geographicAddressElements; VanityAddress = vanityAddress; VanityAddressElements = vanityAddressElements; ReformattedAddressResult = reformattedAddressResult; ReformattedAddress = reformattedAddress; TotalOptions = totalOptions; Options = options; Input = input; var newLinks = new List<Model.Link>(); foreach (Model.Link link in links) { Model.Link newLink; switch (link.Rel) { case "self": newLink = new Model.PostcodeLookup.Link(link.Rel, link.Href); break; default: newLink = link; break; } newLinks.Add(newLink); } Links = newLinks.ToArray(); }
public Task SetMemberVariables(MemberVariables x) { myGrainBytes = (byte[])x.byteArray.Clone(); myGrainString = x.stringVar; myCode = x.code; //RaiseStateUpdateEvent(); return TaskDone.Done; }
public static JobResult CreateSuccessResult(ReturnCode returnCode = ReturnCode.OK) { return new JobResult { Job = new ConcreteJob {JobState = ConcreteJobState.Completed}, ReturnValue = returnCode }; }
private static int Cmd_Help(ReturnCode returncode,string error=null) { WriteLine($"RopPreBuild {Version}"); if (error != null) Tab.Red(error).WriteLine(); WriteLine("Usage:"); Tab.Write("RopPreBuild <").Yellow("prefile").Write(">.pre.cs").WriteLine(" [--<flags>]"); Tab.Write("RopPreBuild ").WriteLine(" --version"); return (int)returncode; }
/** * Check the return status for errors. If there is an error, * then terminate. **/ public static void checkStatus(ReturnCode status, string info) { if (status != ReturnCode.Ok && status != ReturnCode.NoData) { System.Console.WriteLine( "Error in " + info + ": " + getErrorName(status)); System.Environment.Exit(-1); } }
/// <summary> /// Initializes a new instance_ of the Response class by parsing the message reponse. /// </summary> /// <param name="message">A byte array that contains the response message.</param> internal Response(byte[] message) { if (message == null) throw new ArgumentException("message"); // ID - 16 bits // QR - 1 bit // Opcode - 4 bits // AA, TC, RD - 3 bits byte flags1 = message[2]; // RA, Z - 2 bits // RCODE - 4 bits byte flags2 = message[3]; long counts = message[3]; // adjust the return code int return_code = (flags2 & (byte)0x3c) >> 2; return_code_ = (return_code > 6) ? ReturnCode.Other : (ReturnCode)return_code; // other bit flags authoritative_answer_ = ((flags1 & 4) != 0); recursion_available_ = ((flags2 & 128) != 0); truncated_ = ((flags1 & 2) != 0); // create the arrays of response objects questions_ = new Question[GetShort(message, 4)]; answers_ = new Answer[GetShort(message, 6)]; name_servers_ = new NameServer[GetShort(message, 8)]; additional_records_ = new AdditionalRecord[GetShort(message, 10)]; // need a pointer to do this, position just after the header RecordPointer pointer = new RecordPointer(message, 12); // and now populate them, they always follow this order for (int i = 0; i < questions_.Length; i++) { try { questions_[i] = new Question(pointer); } catch(Exception ex) { throw new InvalidResponseException(ex); } } for (int i = 0; i < answers_.Length; i++) { answers_[i] = new Answer(pointer); } for (int i = 0; i < name_servers_.Length; i++) { name_servers_[i] = new NameServer(pointer); } for (int i = 0; i < additional_records_.Length; i++) { additional_records_[i] = new AdditionalRecord(pointer); } }
/// <summary> /// Construct a Response object from the supplied byte array /// </summary> /// <param name="message">a byte array returned from a DNS server query</param> internal Response(byte[] message) { // the bit flags are in bytes 2 and 3 byte flags1 = message[2]; byte flags2 = message[3]; // get return code from lowest 4 bits of byte 3 int returnCode = flags2 & 15; // if its in the reserved section, set to other if (returnCode > 6) returnCode = 6; _returnCode = (ReturnCode)returnCode; // other bit flags _authoritativeAnswer = ((flags1 & 4) != 0); _recursionAvailable = ((flags2 & 128) != 0); _truncated = ((flags1 & 2) != 0); // create the arrays of response objects _questions = new Question[GetShort(message, 4)]; _answers = new Answer[GetShort(message, 6)]; _nameServers = new NameServer[GetShort(message, 8)]; _additionalRecords = new AdditionalRecord[GetShort(message, 10)]; // need a pointer to do this, position just after the header Pointer pointer = new Pointer(message, 12); // and now populate them, they always follow this order for (int index = 0; index < _questions.Length; index++) { try { // try to build a quesion from the response _questions[index] = new Question(pointer); } catch (Exception ex) { Terminals.Logging.Error("DNS Response Question Failure", ex); // something grim has happened, we can't continue throw new InvalidResponseException(ex); } } for (int index = 0; index < _answers.Length; index++) { _answers[index] = new Answer(pointer); } for (int index = 0; index < _nameServers.Length; index++) { _nameServers[index] = new NameServer(pointer); } for (int index = 0; index < _additionalRecords.Length; index++) { _additionalRecords[index] = new AdditionalRecord(pointer); } }
public TKeyRecord(string name, TSigAlgorithm algorithm, DateTime inception, DateTime expiration, TKeyMode mode, ReturnCode error, byte[] key, byte[] otherData) : base(name, RecordType.TKey, RecordClass.Any, 0) { Algorithm = algorithm; Inception = inception; Expiration = expiration; Mode = mode; Error = error; Key = key ?? new byte[] { }; OtherData = otherData ?? new byte[] { }; }
public DataReaderMarshaler(object[] dataValues, SampleInfo[] sampleInfos, ref int maxSamples, ref ReturnCode result) { dataValueHandle = GCHandle.Alloc(dataValues, GCHandleType.Normal); dataValuesPtr = GCHandle.ToIntPtr(dataValueHandle); dataValuesPtrCache = dataValuesPtr; sampleInfoHandle = GCHandle.Alloc(sampleInfos, GCHandleType.Normal); sampleInfosPtr = GCHandle.ToIntPtr(sampleInfoHandle); sampleInfosPtrCache = sampleInfosPtr; result = validateParameters(dataValues, sampleInfos, ref maxSamples); }
private static string GetMessageText(ReturnCode returnCode) { string enumName = Enum.GetName(returnCode.GetType(), returnCode); string resourceName = string.Format("ReturnCode{0}", enumName); string message = Resources.ResourceManager.GetString(resourceName); if (string.IsNullOrEmpty(message)) { message = enumName; } return message; }
public TSigRecord(string name, TSigAlgorithm algorithm, DateTime timeSigned, TimeSpan fudge, ushort originalID, ReturnCode error, byte[] otherData, byte[] keyData) : base(name, RecordType.TSig, RecordClass.Any, 0) { Algorithm = algorithm; TimeSigned = timeSigned; Fudge = fudge; OriginalMac = new byte[] { }; OriginalID = originalID; Error = error; OtherData = otherData ?? new byte[] { }; KeyData = keyData; }
internal Response(byte[] message) { byte flags1 = message[2]; byte flags2 = message[3]; int returnCode = flags2 & 15; if (returnCode > 6) returnCode = 6; _returnCode = (ReturnCode)returnCode; _authoritativeAnswer = ((flags1 & 4) != 0); _recursionAvailable = ((flags2 & 128) != 0); _truncated = ((flags1 & 2) != 0); int _questionsCount = GetShort(message, 4); _questions = new List<Query>(); int _answersCount = GetShort(message, 6); _answers = new List<Answer>(); int _nameServersCount = GetShort(message, 8); _nameServers = new List<NameServer>(); int _additionalRecordsCount = GetShort(message, 10); _additionalRecords = new List<AdditionalRecord>(); SmartPointer pointer = new SmartPointer(message, 12); for (int i = 0; i < _questionsCount; i++) { try { _questions.Add(new Query(pointer)); } catch { throw new Exception("Invalid Response"); } } for (int i = 0; i < _answersCount; i++) { _answers.Add(new Answer(pointer)); } for (int i = 0; i < _nameServersCount; i++) { _nameServers.Add(new NameServer(pointer)); } for (int i = 0; i < _additionalRecordsCount; i++) { _additionalRecords.Add(new AdditionalRecord(pointer)); } }
void reportResultCode(ReturnCode code) { string msg; switch ( code ) { case ReturnCode.Ok: msg = "result is OK"; break; case ReturnCode.Error: msg = "result is ERROR"; break; case ReturnCode.Unsupported: msg = "result is UNSUPPORTED"; break; case ReturnCode.BadParameter: msg = "result is BAD_PARAMETER"; break; case ReturnCode.PreconditionNotMet: msg = "result is PRECONDITION_NOT_MET"; break; case ReturnCode.OutOfResources: msg = "result is OUT_OF_RESOURCES"; break; case ReturnCode.NotEnabled: msg = "result is NOT_ENABLED"; break; case ReturnCode.ImmutablePolicy: msg = "result is IMMUTABLE_POLICY"; break; case ReturnCode.InconsistentPolicy: msg = "result is INCONSISTENT_POLICY"; break; case ReturnCode.AlreadyDeleted: msg = "result is ALREADY_DELETED"; break; case ReturnCode.Timeout: msg = "result is TIMEOUT"; break; case ReturnCode.NoData: msg = "result is NO_DATA"; break; default: msg = "result is UNKNOWN"; break; } tfw.TestMessage(TestMessage.Note, msg); }
/// <summary> /// Throws an <see cref="SpssException"/> if a prior call into SPSS failed. /// </summary> /// <param name="returnCode">The return code actually received from the SPSS function.</param> /// <param name="spssFunctionName">Name of the SPSS function invoked.</param> /// <param name="acceptableReturnCodes">The acceptable return codes that should not result in a thrown exception (SPSS_OK is always ok).</param> /// <returns>The value of <paramref name="returnCode"/>.</returns> internal static ReturnCode ThrowOnFailure(ReturnCode returnCode, string spssFunctionName, params ReturnCode[] acceptableReturnCodes) { if (returnCode == ReturnCode.SPSS_OK) { return returnCode; } if (acceptableReturnCodes != null) { if (Array.IndexOf(acceptableReturnCodes, returnCode) >= 0) { return returnCode; } } throw new SpssException(returnCode, spssFunctionName); }
/// <summary> /// Erstellt einen neuen Datensatz mit den übergebenen Eigenschaften. /// Wird ein Fehler zurückgegeben (ReturnCode != noError) so ist ein null Datensatz erstellt worden, /// welcher gelöscht werden sollte. /// </summary> /// <param name="benutzer">Benutzername</param> /// <param name="passw">Passwort</param> /// <param name="webs">Webseite der Zugangsdaten oder Pfad zur User-Datei</param> /// <param name="detail">Zusätzliche Infos (optional)</param> /// <param name="code">Rückgabe des ReturnCode</param> public Data(string benutzer, Passw passw, string webs, string detail, out ReturnCode code) { code = ReturnCode.noError; if (Benutzer.CheckBenutzername(benutzer) == true) code = ReturnCode.BenutzernameUngültig; Program.stopw.Restart(); if (Passw.CheckPasswort(passw.Passwort, passw.PasswortEigenschaften) == true) code = ReturnCode.PasswortUngültig; Program.stopw.Stop(); if (webs == null) code = ReturnCode.missingParameter; if (code == ReturnCode.noError) { this.benutzername = benutzer; this.passwort = passw; this.pfad = webs; this.details = detail; } }
public void OnDataAvailable(IDataReader entityInterface) { Msg[] msgList = null ; SampleInfo[] infoSeq = null; status = msgDR.Read(ref msgList, ref infoSeq, Length.Unlimited, SampleStateKind.Any, ViewStateKind.New, InstanceStateKind.Any); ErrorHandler.checkStatus(status, "DataReader.Read"); if (msgList != null && msgList.Length > 0) { Console.WriteLine("=== [ListenerDataListener::OnDataAvailable] - msgList.Length : {0}", msgList.Length); foreach (Msg msg in msgList) { Console.WriteLine(" --- Message Received ---"); Console.WriteLine(" userId : {0}", msg.userID); Console.WriteLine(" message : \\ {0}",msg.message); } status = msgDR.ReturnLoan(ref msgList, ref infoSeq); ErrorHandler.checkStatus(status, "DataReader.ReturnLoan"); } guardCond.SetTriggerValue(true); }
public AniDBResponse(byte[] responseData, Encoding encoding = null) { OriginalString = (encoding ?? Encoding.ASCII).GetString(responseData); string[] responseLines = OriginalString.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); short returnCode; string[] response = responseLines[0].Split(new[] { ' ' }, short.TryParse(responseLines[0].Split(' ')[0], out returnCode) ? 2 : 3); Tag = response.Length == 3 ? response[0] : ""; Code = (ReturnCode)(response.Length == 3 ? short.Parse(response[1]) : returnCode); ReturnString = response.Length == 3 ? response[2] : response[1]; List<string[]> datafields = new List<string[]>(); for (int i = 1; i < responseLines.Length; i++) datafields.Add(responseLines[i].Split('|')); DataFields = datafields.ToArray(); }
public DnsAnswer(byte[] response) { _questions = new List<Question>(); _answers = new List<Answer>(); _servers = new List<Server>(); _additional = new List<Record>(); _exceptions = new List<Exception>(); DataBuffer buffer = new DataBuffer(response, 2); byte bits1 = buffer.ReadByte(); byte bits2 = buffer.ReadByte(); //Mask off return code int returnCode = bits2 & 15; if (returnCode > 6) returnCode = 6; this._returnCode = (ReturnCode)returnCode; //Get Additional Flags _authoritative = TestBit(bits1, 2); _recursive = TestBit(bits2, 8); _truncated = TestBit(bits1, 1); int nQuestions = buffer.ReadBEShortInt(); int nAnswers = buffer.ReadBEShortInt(); int nServers = buffer.ReadBEShortInt(); int nAdditional = buffer.ReadBEShortInt(); //read in questions for (int i = 0; i < nQuestions; i++) { try { _questions.Add(new Question(buffer)); } catch (Exception ex) { _exceptions.Add(ex); } } //read in answers for (int i = 0; i < nAnswers; i++) { try { _answers.Add(new Answer(buffer)); } catch (Exception ex) { _exceptions.Add(ex); } } //read in servers for (int i = 0; i < nServers; i++) { try { _servers.Add(new Server(buffer)); } catch (Exception ex) { _exceptions.Add(ex); } } //read in additional records for (int i = 0; i < nAdditional; i++) { try { _additional.Add(new Record(buffer)); } catch (Exception ex) { _exceptions.Add(ex); } } }
public MemberVariables(byte[] bytes, string str, ReturnCode codeInput) { byteArray = bytes; stringVar = str; code = codeInput; }
/// <summary> /// Register the type we are interested with the DDS Infrastructure /// </summary> /// <param name="ts">The TypeSupport class</param> public void registerType(ITypeSupport ts) { typeName = ts.TypeName; status = ts.RegisterType(participant, typeName); ErrorHandler.checkStatus(status, "ITypeSupport.RegisterType"); }
/// <summary> /// Delete the DomainParticipant. /// </summary> public void deleteParticipant() { status = dpf.DeleteParticipant(participant); ErrorHandler.checkStatus(status, "DomainParticipantFactory.DeleteParticipant"); }
/// <summary> /// Creates a DataReader /// </summary> /// <param name="exampleNameToCreateReaderFor">The example name to create the /// DataReader for. This param is used to define any specific Qos values the /// example requires.</param> /// <param name="filtered">This param determines whether a reader will be created /// for a normal or filtered topic.</param> public void createReader(Boolean filtered) { status = subscriber.GetDefaultDataReaderQos(ref RQosH); ErrorHandler.checkStatus(status, "Subscriber.GetDefaultDataReaderQoS"); status = subscriber.CopyFromTopicQos(ref RQosH, topicQos); ErrorHandler.checkStatus(status, "Subscriber.CopyFromTopicQoS"); switch (exampleName) { case "ContentFilteredTopic": case "Listener": RQosH.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; break; case "Durability": if (durabilityKind.Equals("transient")) RQosH.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos; else RQosH.Durability.Kind = DurabilityQosPolicyKind.PersistentDurabilityQos; break; case "HelloWorld": case "Ownership": case "WaitSet": case "QueryCondition": case "Lifecycle": break; default: break; } if (filtered) { reader = subscriber.CreateDataReader( filteredTopic, RQosH, null, StatusKind.Any); } else { reader = subscriber.CreateDataReader( topic, RQosH, null, StatusKind.Any); } ErrorHandler.checkHandle(reader, "Subscriber.CreateDataReader"); }
/// <summary> /// Creates a Subscriber /// </summary> public void createSubscriber() { status = participant.GetDefaultSubscriberQos(ref subQos); ErrorHandler.checkStatus(status, "DomainParticipant.GetDefaultSubscriberQos"); subQos.Partition.Name = new String[1]; subQos.Partition.Name[0] = partitionName; subscriber = participant.CreateSubscriber( subQos, null, StatusKind.Any); ErrorHandler.checkHandle(subscriber, "DomainParticipant.CreateSubscriber"); }
/// <summary> /// Method to delete a data writer. /// </summary> /// <param name="dataWriter">The DataWriter instance to delete.</param> public void deleteWriter(IDataWriter dataWriter) { status = publisher.DeleteDataWriter(dataWriter); ErrorHandler.checkStatus(status, "Publisher.DeleteDataWriter"); }
private static int Main(string[] args) { Console.WriteLine("Community TFS Build Manager Console - {0}\n", GetFileVersion(Assembly.GetExecutingAssembly())); try { // --------------------------------------------------- // Process the arguments // --------------------------------------------------- int retval = ProcessArguments(args); if (retval != 0) { return retval; } switch (action) { case ConsoleAction.ExportBuildDefinitions: // --------------------------------------------------- // Export the specified builds // --------------------------------------------------- retval = ExportBuilds(); if (retval != 0) { return retval; } break; } } catch (Exception ex) { string message = ex.Message; if (ex.InnerException != null) { message += string.Format("Inner Exception: {0}", ex.InnerException.Message); } rc = ReturnCode.UnhandledException; LogMessage(message); return (int)rc; } return (int)rc; }
private static int ProcessArguments(string[] args) { if (args.Contains("/?") || args.Contains("/help")) { Console.WriteLine(@"Syntax:\t\ctfsbm.exe /f:<files> | /auto [switches]\n"); Console.WriteLine("Optional Switches:\t\t\n"); Console.WriteLine("Samples:\t\t\n"); return (int)ReturnCode.UsageRequested; } Console.Write("Processing Arguments"); if (args.Length == 0) { rc = ReturnCode.ArgumentsNotSupplied; LogMessage(); return (int)rc; } Regex searchTerm = new Regex(@"/p:.*", RegexOptions.IgnoreCase); bool propertiesargumentfound = args.Select(arg => searchTerm.Match(arg)).Any(m => m.Success); if (propertiesargumentfound) { // properties = args.First(item => item.Contains("/p:")).Replace("/p:", string.Empty).Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } Console.Write("...Success\n"); return 0; }
/// <summary> /// Deletes the class's Subscriber /// </summary> public void deleteSubscriber() { status = participant.DeleteSubscriber(subscriber); ErrorHandler.checkStatus(status, "Participant.DeleteSubscriber"); }