// // Summary: // Marshals the PolicyElement to it's native format. // // Parameters: // ptr - A pointer to native memory in which to place the native format of the PolicyElement. Must be // a buffer atleast as large as this.Size. // public void DoMarshal(IntPtr ptr) { string target = m_element.Target.OuterXml; string issuer = ""; IDT.DebugAssert(IntPtr.Zero == m_nativePtr, "Pointer already assigned"); m_nativePtr = ptr; if (m_element.Issuer != null) { issuer = m_element.Issuer.OuterXml; } string tokenParameters = string.Empty; if (null != m_element.Parameters) { tokenParameters = CardSpaceSelector.XmlToString(m_element.Parameters); } m_nativeElement.targetEndpointAddress = target; m_nativeElement.issuerEndpointAddress = issuer; m_nativeElement.issuedTokenParameters = tokenParameters; m_nativeElement.policyNoticeLink = null != m_element.PolicyNoticeLink ? m_element.PolicyNoticeLink.ToString() : null; m_nativeElement.policyNoticeVersion = m_element.PolicyNoticeVersion; m_nativeElement.isManagedCardProvider = m_element.IsManagedIssuer; Marshal.StructureToPtr(m_nativeElement, ptr, false); return; }
public static HGlobalSafeHandle Construct(string managedString) { IDT.DebugAssert(!String.IsNullOrEmpty(managedString), "null string"); int bytes = (managedString.Length + 1) * 2; return(new HGlobalSafeHandle(Marshal.StringToHGlobalUni(managedString), bytes)); }
// // Summary: // Zero the string contents and release the handle // protected override bool ReleaseHandle() { IDT.DebugAssert(!IsInvalid, "handle is invalid in release handle"); IDT.DebugAssert(0 != m_bytes, "invalid size"); ZeroMemory(base.handle, m_bytes); Marshal.FreeHGlobal(base.handle); return(true); }
public static HGlobalSafeHandle Construct(int bytes) { IDT.DebugAssert(bytes > 0, "attempt to allocate a handle with <= 0 bytes"); return(new HGlobalSafeHandle(Marshal.AllocHGlobal(bytes), bytes)); }
// // Parameters: // errorString - If Value gets assigned to more than once an argument exception will be thrown with this // string as the Exception string. // public ThrowOnMultipleAssignment(string errorString) { IDT.DebugAssert(!String.IsNullOrEmpty(errorString), "Must have an error string"); m_errorString = errorString; }